public OperationResult Update(SimpleSiteModel simpleSiteModel) { try { Core core = _coreHelper.GetCore(); var siteDto = core.SiteRead(simpleSiteModel.Id); if (siteDto.WorkerUid != null) { var workerDto = core.Advanced_WorkerRead((int)siteDto.WorkerUid); if (workerDto != null) { string fullName = simpleSiteModel.UserFirstName + " " + simpleSiteModel.UserLastName; var isUpdated = core.SiteUpdate(simpleSiteModel.Id, fullName, simpleSiteModel.UserFirstName, simpleSiteModel.UserLastName, workerDto.Email); return(isUpdated ? new OperationResult(true, LocaleHelper.GetString("DeviceUserUpdatedSuccessfully")) : new OperationResult(false, LocaleHelper.GetString("DeviceUserParamCouldNotBeUpdated", simpleSiteModel.Id))); } return(new OperationResult(false, LocaleHelper.GetString("DeviceUserCouldNotBeObtained"))); } return(new OperationResult(false, LocaleHelper.GetString("DeviceUserNotFound"))); } catch (Exception) { return(new OperationResult(false, LocaleHelper.GetString("DeviceUserCouldNotBeUpdated"))); } }
public OperationResult Update(SimpleSiteModel simpleSiteModel) { try { Core core = _coreHelper.GetCore(); var siteDto = core.SiteRead(simpleSiteModel.Id); if (siteDto.WorkerUid != null) { var workerDto = core.Advanced_WorkerRead((int)siteDto.WorkerUid); if (workerDto != null) { string fullName = simpleSiteModel.UserFirstName + " " + simpleSiteModel.UserLastName; var isUpdated = core.SiteUpdate(simpleSiteModel.Id, fullName, simpleSiteModel.UserFirstName, simpleSiteModel.UserLastName, workerDto.Email); return(isUpdated ? new OperationResult(true, "Device User updated successfully") : new OperationResult(false, $"Device User with id {simpleSiteModel.Id} could not be updated!")); } return(new OperationResult(false, "Device User with such UId could not be obtained")); } return(new OperationResult(false, "Device User UId not found")); } catch (Exception) { return(new OperationResult(false, "Device User could not be updated")); } }
public OperationResult Create(SimpleSiteModel simpleSiteModel) { if (!ModelState.IsValid) { return(new OperationResult(false, "Device User could not be created!")); } Core core = _coreHelper.GetCore(); string siteName = simpleSiteModel.UserFirstName + " " + simpleSiteModel.UserLastName; var siteDto = core.SiteCreate(siteName, simpleSiteModel.UserFirstName, simpleSiteModel.UserLastName, null); return(siteDto != null ? new OperationResult(true, $"Device User \"{siteDto.SiteName}\" created successfully") : new OperationResult(false, "Device User could not be created!")); }
public OperationResult Create(SimpleSiteModel simpleSiteModel) { if (!ModelState.IsValid) { return(new OperationResult(false, LocaleHelper.GetString("DeviceUserCouldNotBeCreated"))); } Core core = _coreHelper.GetCore(); string siteName = simpleSiteModel.UserFirstName + " " + simpleSiteModel.UserLastName; try { var siteDto = core.SiteCreate(siteName, simpleSiteModel.UserFirstName, simpleSiteModel.UserLastName, null); return(siteDto != null ? new OperationResult(true, LocaleHelper.GetString("DeviceUserParamCreatedSuccessfully", siteDto.SiteName)) : new OperationResult(false, LocaleHelper.GetString("DeviceUserCouldNotBeCreated"))); } catch (Exception ex) { try { if (ex.InnerException.Message == "The remote server returned an error: (402) Payment Required.") { return(new OperationResult(false, LocaleHelper.GetString("YouNeedToBuyMoreLicenses"))); } else { return(new OperationResult(false, LocaleHelper.GetString("DeviceUserCouldNotBeCreated"))); } } catch { return(new OperationResult(false, LocaleHelper.GetString("DeviceUserCouldNotBeCreated"))); } } }
public OperationResult Create(SimpleSiteModel simpleSiteModel) { if (!ModelState.IsValid) { return(new OperationResult(false, "Device User could not be created!")); } Core core = _coreHelper.GetCore(); string siteName = simpleSiteModel.UserFirstName + " " + simpleSiteModel.UserLastName; try { var siteDto = core.SiteCreate(siteName, simpleSiteModel.UserFirstName, simpleSiteModel.UserLastName, null); return(siteDto != null ? new OperationResult(true, $"Device User \"{siteDto.SiteName}\" created successfully") : new OperationResult(false, "Device User could not be created!")); } catch (Exception ex) { try { if (ex.InnerException.Message == "The remote server returned an error: (402) Payment Required.") { return(new OperationResult(false, "You need to buy more licenses for additional units to be added.")); } else { return(new OperationResult(false, "Device User could not be created!")); } } catch { return(new OperationResult(false, "Device User could not be created!")); } } }