2 // HMAirCorpsChangeNameCommand.m
5 // Created by Hori,Masaki on 2016/12/04.
6 // Copyright © 2016年 Hori,Masaki. All rights reserved.
9 #import "HMAirCorpsChangeNameCommand.h"
11 #import "HMKCAirBase.h"
12 #import "HMKCAirBasePlaneInfo.h"
13 #import "HMKCMaterial.h"
15 #import "HMServerDataStore.h"
17 @implementation HMAirCorpsChangeNameCommand
20 static dispatch_once_t onceToken;
21 dispatch_once(&onceToken, ^{
22 [HMJSONCommand registerClass:self];
26 + (BOOL)canExcuteAPI:(NSString *)api
28 if([api isEqualToString:@"/kcsapi/api_req_air_corps/change_name"]) return YES;
34 HMServerDataStore *store = [HMServerDataStore oneTimeEditor];
37 NSString *areaId = self.arguments[@"api_area_id"];
38 NSString *rId = self.arguments[@"api_base_id"];
39 NSArray<HMKCAirBase *> *airBases = [store objectsWithEntityName:@"AirBase"
42 predicateFormat:@"area_id == %@ AND rid == %@", @(areaId.integerValue), @(rId.integerValue)];
43 if(airBases.count == 0) { return; }
45 airBases[0].name = self.arguments[@"api_name"];