public AjaxResponse Update([FromBody] CIDRSettingModel model, string id) { AjaxResponse response = new AjaxResponse(); response.IsSuccess = true; try { if (model == null || String.IsNullOrWhiteSpace(model.IPStart) || String.IsNullOrWhiteSpace(model.IPEnd) || model.TCPFaZhi <= 0 || model.TCPPort <= 0 || model.TTLFaZhi <= 0 ) { response.IsSuccess = false; response.Message = "请求的数据格式不正确。"; return response; //throw new BadRequestException("请求的数据不能为空。"); } model.ID = id; model.LastUpdatedBy = Context.LoginName; CIDRSettingRepository rep = new CIDRSettingRepository(); rep.UpdateSetting(model); } catch (Exception ex) { response.IsSuccess = false; response.Message = ex.Message; } return response; }
public AjaxResponse DeleteSetting(string settingid) { AjaxResponse response = new AjaxResponse(); response.IsSuccess = true; try { if (string.IsNullOrWhiteSpace(settingid)) { response.IsSuccess = false; response.Message = "settingid 不能为空."; return response; } CIDRSettingRepository rep = new CIDRSettingRepository(); rep.DeleteSetting(settingid); } catch (Exception ex) { response.IsSuccess = false; response.Message = ex.Message; } return response; }
public AjaxResponse DeleteUser(string userid) { var response = new AjaxResponse(); try { if ("Administrator".Equals(userid, StringComparison.OrdinalIgnoreCase)) { response.IsSuccess = false; response.Message = "Administrator账号不能被删除。"; return response; } UserBusiness ub = new UserBusiness(); var user = ub.GetUser(Context.LoginName); // 2 means 客户端用户 if (user.UserType == 2) { response.IsSuccess = false; response.Message = "终端用户没有权限进行此操作。"; return response; } ub.DeleteUser(userid); response.IsSuccess = true; } catch (Exception ex) { response.IsSuccess = false; response.Message = ex.Message; } return response; }
public AjaxResponse Update([FromBody]UpdateUserRequest request, string userid) { if (request == null) { throw new BadRequestException(); } var response = new AjaxResponse(); UserBusiness ub = new UserBusiness(); try { if ("Administrator".Equals(userid, StringComparison.OrdinalIgnoreCase)) { response.IsSuccess = false; response.Message = "不能修改Administrator密码。"; return response; } var user = ub.GetUser(userid); // 2 means 客户端用户 if (user.UserType == 2) { response.IsSuccess = false; response.Message = "终端用户没有权限修改密码。"; return response; } UserRepository ur = new UserRepository(); User dbUser = new Repositories.User(); dbUser.UserName = userid; dbUser.FullName = request.Name; dbUser.Phone = request.Phone; dbUser.City = request.City; dbUser.Description = request.Description; ur.UpdateUser(dbUser); response.IsSuccess = true; } catch (Exception ex) { response.IsSuccess = false; response.Message = ex.Message; } return response; }