예제 #1
0
        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);
        }
예제 #2
0
        public DeviceRolePermissionViewModel(DeviceRolePermission deviceRolePermission)
        {
            SaveCmd   = new RelayCommand(Save);
            CancelCmd = new RelayCommand(() => Close(""));

            FromCoreModel(deviceRolePermission);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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;
        }
예제 #6
0
        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);
        }