} // 1 : Customer , 2 : Merchant public CustomerBaseModels() { CustomerDetail = new CustomerDetailModels(); MerchantStore = new MerchantModels(); ProductManagement = new ProductManagementModels(); IndexTab = 1; }
public ProductManagementModels GetListDataProductsManagement(string CustomerID) { ProductManagementModels item = new ProductManagementModels(); List <HardwareServiceModels> ListHardwareService = new List <HardwareServiceModels>(); List <ProductPackageModels> ListProductPackage = new List <ProductPackageModels>(); List <AdditionFunctionModels> ListFunction = new List <AdditionFunctionModels>(); List <AccountManagementModels> ListAccount = new List <AccountManagementModels>(); try { CustomerRequest paraBody = new CustomerRequest(); NSLog.Logger.Info("GetListDataProductsManagement Request: ", paraBody); paraBody.ID = CustomerID; var result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.customerAPIProductsManagement, null, paraBody); dynamic data = result.Data; var lstDataRaw = data["ListHardwareService"]; var lstObject = JsonConvert.SerializeObject(lstDataRaw); ListHardwareService = JsonConvert.DeserializeObject <List <HardwareServiceModels> >(lstObject); lstDataRaw = data["ListProductPackage"]; lstObject = JsonConvert.SerializeObject(lstDataRaw); ListProductPackage = JsonConvert.DeserializeObject <List <ProductPackageModels> >(lstObject); lstDataRaw = data["ListFunction"]; lstObject = JsonConvert.SerializeObject(lstDataRaw); ListFunction = JsonConvert.DeserializeObject <List <AdditionFunctionModels> >(lstObject); lstDataRaw = data["ListAccount"]; lstObject = JsonConvert.SerializeObject(lstDataRaw); ListAccount = JsonConvert.DeserializeObject <List <AccountManagementModels> >(lstObject); NSLog.Logger.Info("GetListDataProductsManagement", item); if (ListHardwareService != null) { ListHardwareService.ForEach(x => x.BoughtTime = x.BoughtTime.HasValue ? CommonHelper.ConvertToLocalTime(x.BoughtTime.Value) : x.BoughtTime); } if (ListProductPackage != null) { ListProductPackage.ForEach(x => { x.BoughtTime = x.BoughtTime.HasValue ? CommonHelper.ConvertToLocalTime(x.BoughtTime.Value) : x.BoughtTime; x.ActivateTime = x.ActivateTime.HasValue ? CommonHelper.ConvertToLocalTime(x.ActivateTime.Value) : x.ActivateTime; x.ExpiryDate = x.ExpiryDate.HasValue ? CommonHelper.ConvertToLocalTime(x.ExpiryDate.Value) : x.ExpiryDate; }); } if (ListAccount != null) { ListAccount.ForEach(x => { x.ActivateTime = x.ActivateTime.HasValue ? CommonHelper.ConvertToLocalTime(x.ActivateTime.Value) : x.ActivateTime; x.ExpiryDate = x.ExpiryDate.HasValue ? CommonHelper.ConvertToLocalTime(x.ExpiryDate.Value) : x.ExpiryDate; }); } if (ListFunction != null) { ListFunction.ForEach(x => { x.ActivateTime = x.ActivateTime.HasValue ? CommonHelper.ConvertToLocalTime(x.ActivateTime.Value) : x.ActivateTime; x.ExpiryDate = x.ExpiryDate.HasValue ? CommonHelper.ConvertToLocalTime(x.ExpiryDate.Value) : x.ExpiryDate; }); } item.ListHardwareService = ListHardwareService; item.ListProductPackage = ListProductPackage; item.ListFunction = ListFunction; item.ListAccount = ListAccount; return(item); } catch (Exception e) { NSLog.Logger.Error("GetListDataProductsManagement", e); return(item); } }