2 // UpdateSlotItemCommand.swift
5 // Created by Hori,Masaki on 2017/01/10.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 class UpdateSlotItemCommand: JSONCommand {
12 override func execute() {
13 guard let d = json["api_data"] as? [String: Any]
14 else { return print("api_data is wrong") }
15 guard let data = d["api_slot_item"] as? [String: Any],
16 let slotItemId = data["api_slotitem_id"] as? Int
18 guard let newSlotItemId = data["api_id"] as? Int
19 else { return print("api_id is wrong") }
20 let store = ServerDataStore.oneTimeEditor()
21 guard let masterSlotItem = store.masterSlotItem(by: slotItemId)
22 else { return print("MasterSlotItem is not found") }
23 guard let new = store.createSlotItem()
24 else { return print("Can not create new SlotItem") }
25 new.id = newSlotItemId
26 new.master_slotItem = masterSlotItem