private List <DeviceRolePermission> GetDeviceRolePermissionFromUI() { var result = new List <DeviceRolePermission>(); var selected = DeviceDtos.FindAll(x => x.IsSelected); foreach (var checkboxItem in selected) { var rolePermission = CurrentDeviceRole.DeviceRolePermissions.FirstOrDefault(x => x.DeviceID == checkboxItem.ID); if (rolePermission == null) { rolePermission = new DeviceRolePermission() { DeviceID = checkboxItem.ID, DeviceRoleID = CurrentDeviceRole.DeviceRoleID, Enable = true, STARTDATE = DateTime.Now, }; } rolePermission.PermissionAction = (DevicePermissionAction)SelectedPermissionAction; rolePermission.AllowedAccessTimeZoneID = SelectedTimezone.TimeZoneID; result.Add(rolePermission); } return(result); }
public DeviceRolePermissionViewModel(DeviceRolePermission deviceRolePermission) { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); FromCoreModel(deviceRolePermission); }
public HttpResponseMessage Post([FromBody] DeviceRolePermission deviceRolePermissionInfo) { return(ActionWarpper.Process(deviceRolePermissionInfo, OperationCodes.ADVRLPMS, () => { var repo = RepositoryManager.GetRepository <IDeviceRolePermissionRepository>(); repo.Insert(deviceRolePermissionInfo); return Request.CreateResponse(HttpStatusCode.OK, deviceRolePermissionInfo); }, this)); }
public HttpResponseMessage Put(int id, [FromBody] DeviceRolePermission deviceRolePermissionInfo) { return(ActionWarpper.Process(deviceRolePermissionInfo, OperationCodes.MDVRLPMS, () => { deviceRolePermissionInfo.DeviceRolePermissionID = id; var repo = RepositoryManager.GetRepository <IDeviceRolePermissionRepository>(); repo.Update(deviceRolePermissionInfo); return Request.CreateResponse(HttpStatusCode.OK); }, this)); }
private void FromCoreModel(DeviceRolePermission permission) { SelectedDevice = AuthorizationDevices.FirstOrDefault(x => x.DeviceID == permission.DeviceID); SelectedTimezone = AuthorizationTimezones.FirstOrDefault(x => x.TimeZoneID == permission.AllowedAccessTimeZoneID); Id = permission.DeviceRolePermissionID; DeviceRoleID = permission.DeviceRoleID; Name = SelectedDevice.Name; PermissionAction = permission.PermissionAction; UserGroupVM = permission.UserGroupVM; STARTDATE = permission.STARTDATE; Enddate = permission.Enddate; }
public DeviceRolePermission ToCoreModel() { DeviceRolePermission permission = new DeviceRolePermission(); permission.DeviceRolePermissionID = Id; permission.DeviceID = SelectedDevice.DeviceID; permission.DeviceRoleID = DeviceRoleID; permission.Enable = true; permission.PermissionAction = PermissionAction; permission.UserGroupVM = UserGroupVM; permission.AllowedAccessTimeZoneID = SelectedTimezone.TimeZoneID; permission.STARTDATE = STARTDATE; permission.Enddate = Enddate; return(permission); }