Beispiel #1
0
        public IActionResult Edit(UserEditViewModel model)
        {
            ResponseModel response = ResponseModelFactory.CreateInstance;

            if (ConfigurationManager.AppSettings.IsTrialVersion)
            {
                response.SetIsTrial();
                return(Ok(response));
            }
            using (_dbContext)
            {
                DncUser entity = _dbContext.DncUser.FirstOrDefault(x => x.Guid == model.Guid);
                if (entity == null)
                {
                    response.SetFailed("用户不存在");
                    return(Ok(response));
                }
                entity.DisplayName        = model.DisplayName;
                entity.IsDeleted          = model.IsDeleted;
                entity.IsLocked           = model.IsLocked;
                entity.ModifiedByUserGuid = AuthContextService.CurrentUser.Guid;
                entity.ModifiedByUserName = AuthContextService.CurrentUser.DisplayName;
                entity.ModifiedOn         = DateTime.Now;
                entity.Password           = model.Password;
                entity.Status             = model.Status;
                entity.UserType           = model.UserType;
                entity.Description        = model.Description;
                _dbContext.SaveChanges();
                response = ResponseModelFactory.CreateInstance;
                return(Ok(response));
            }
        }
Beispiel #2
0
        public IActionResult Delete(string ids)
        {
            ResponseModel response = ResponseModelFactory.CreateInstance;

            if (ConfigurationManager.AppSettings.IsTrialVersion)
            {
                response.SetIsTrial();
                return(Ok(response));
            }
            response = UpdateIsDelete(CommonEnum.IsDeleted.Yes, ids);
            return(Ok(response));
        }
Beispiel #3
0
        public IActionResult Batch(string command, string ids)
        {
            ResponseModel response = ResponseModelFactory.CreateInstance;

            switch (command)
            {
            case "delete":
                if (ConfigurationManager.AppSettings.IsTrialVersion)
                {
                    response.SetIsTrial();
                    return(Ok(response));
                }
                response = UpdateIsDelete(CommonEnum.IsDeleted.Yes, ids);
                break;

            case "recover":
                response = UpdateIsDelete(CommonEnum.IsDeleted.No, ids);
                break;

            case "forbidden":
                if (ConfigurationManager.AppSettings.IsTrialVersion)
                {
                    response.SetIsTrial();
                    return(Ok(response));
                }
                response = UpdateStatus(UserStatus.Forbidden, ids);
                break;

            case "normal":
                response = UpdateStatus(UserStatus.Normal, ids);
                break;

            default:
                break;
            }
            return(Ok(response));
        }