public Task <OperatorDto> Update(OperatorDto operatorDto) { Operator operatorModel = ObjectMapper.Map <Operator>(operatorDto); operatorModel = _operatorRepository.Update(operatorModel); return(Task.FromResult <OperatorDto>(operatorDto)); }
public async Task <bool> Create(OperatorDto operatorDto) { _logger.Info($"Fingding by Email an operator {operatorDto.Email} "); var user = await _unitOfWork.UserManager.FindByEmailAsync(operatorDto.Email); if (user != null) { return(false); } user = new IdentityUser { Email = operatorDto.Email, UserName = operatorDto.Email }; var result = await _unitOfWork.UserManager.CreateAsync(user, operatorDto.Password); if (result.Errors.Count() != 0) { throw new Exception(); } _logger.Info($"Adding the role to new operator."); await _unitOfWork.UserManager.AddToRoleAsync(user.Id, "Operator"); var profile = _mapper.Map <Operator>(operatorDto); profile.AppCustomer = user; _unitOfWork.OperatorGenericRepository.Create(profile); return(true); }
private bool CanExecuteUpdateCommand(OperatorDto operatorDto) { //不能操作当前用户 var can = operatorDto != null && !IsBusy; return(can); }
private bool CanExecuteActiveCommand(OperatorDto param) { //不能操作当前用户 var can = !IsBusy && param != null && UIExt.Communicate.LoginInfo.Account != param.Account; return(can); }
public async Task <OperationDetails> Create(OperatorDto operatorDto) { var _operator = await this._auow.OperatorManager.FindByEmailAsync(operatorDto.Email); if (_operator == null) { _operator = new ApplicationOperator { Email = operatorDto.Email, UserName = operatorDto.Email }; var _result = await this._auow.OperatorManager.CreateAsync(_operator, operatorDto.Password); if (_result.Errors.Count() > 0) { return(new OperationDetails(false, _result.Errors.FirstOrDefault(), "")); } await this._auow.OperatorManager.AddToRoleAsync(_operator.Id, operatorDto.Role); await this._auow.SaveAsync(); return(new OperationDetails(true, "Successfull registration", "")); } else { return(new OperationDetails(false, "Email is not unique", "Email")); } }
public async Task <ActionResult> Login(LoginViewModel loginModel) { await this._SetInitialData(); if (ModelState.IsValid) { var _operatorDto = new OperatorDto { Email = loginModel.Email, Password = loginModel.Password }; var _claim = await this._OperatorService.Authenticate(_operatorDto); if (_claim != null) { this._Authentication.SignOut(); this._Authentication.SignIn(new AuthenticationProperties { IsPersistent = true }, _claim); return(RedirectToAction("Index", "Job")); } else { ModelState.AddModelError("", "Invalid login or password"); } } return(View(loginModel)); }
public async Task <ActionResult> Register(RegisterViewModel registerModel) { await this._SetInitialData(); if (ModelState.IsValid) { var _userDto = new OperatorDto { Email = registerModel.Email, Password = registerModel.Password, Role = "User" }; var _result = await this._OperatorService.Create(_userDto); if (_result.Succeeded) { return(View("SuccessRegister")); } else { ModelState.AddModelError(_result.Property, _result.Message); } } else { var _duplicatedModelState = ModelState.Values.SingleOrDefault(ms => ms.Errors.Count > 1 && ms.Errors[0].ErrorMessage == ms.Errors[1].ErrorMessage); if (_duplicatedModelState != null) { _duplicatedModelState.Errors.Remove(_duplicatedModelState.Errors[1]); } } return(View(registerModel)); }
public void UpdateOperator(OperatorDto operatorDto) { if (operatorDto == null) { throw new CustomException(500, "Operator is null"); } string code = AuthManager.GetCurrentUser().Code; var businessman = businessmanRepository.FindAll(x => x.Code == code).FirstOrDefault(); if (businessman == null) { throw new CustomException(404, "商户不存在"); } var oModel = businessman.Operators.Where(p => p.Id == operatorDto.Id).FirstOrDefault(); if (oModel == null) { throw new CustomException(404, "修改操作员不存在"); } oModel.Realname = operatorDto.Realname; oModel.Phone = operatorDto.Phone; oModel.Tel = operatorDto.Tel; unitOfWorkRepository.PersistUpdateOf(businessman); unitOfWork.Commit(); }
public async Task <OperatorDto> GetById(int id) { Operator result = await _operatorRepository.GetAsync(id); OperatorDto dto = ObjectMapper.Map <OperatorDto>(result); return(dto); }
public OperatorDto Create(OperatorDto dto) { var operatorDB = Mapper.Map <OperatorDto, Operator>(dto); _operatorRepository.Create(operatorDB); return(Mapper.Map <Operator, OperatorDto>(_operatorRepository.FindById(operatorDB.Id))); }
private void ExecuteResetPswCommand(OperatorDto obj) { CommunicateManager.Invoke <IBusinessmanService>(p => { p.ResetPassword(obj.Account); UIManager.ShowMessage("修改成功"); }, UIManager.ShowErr); }
public Task <OperatorDto> Create(OperatorDto operatorDto) { operatorDto.CreatorUserId = AbpSession.UserId.Value; operatorDto.CreationTime = DateTime.Now; Operator operatorModel = ObjectMapper.Map <Operator>(operatorDto); operatorDto.Id = _operatorRepository.InsertAndGetId(operatorModel); return(Task.FromResult <OperatorDto>(operatorDto)); }
///// <summary> ///// 取消命令 ///// </summary> //public ICommand CancelCommand //{ // get // { // return new RelayCommand(() => // { // Messenger.Default.Send<bool>(false, "CloseAddOperator"); // }); // } //} #endregion private void InitlizeEdit(OperatorDto operatorDto) { operatorDto.Password = "******"; Operator = operatorDto; //Operator.Password = ""; ComparisonPassword = "******"; IsAddMode = false; Title = "修改员工"; }
private void ExecuteUpdateCommand(OperatorDto operatorDto) { LocalUIManager.ShowOperatorDialog(operatorDto, result => { if (result == null || !result.Value) { return; } Refresh(operatorDto); }); }
public async Task <ClaimsIdentity> Authenticate(OperatorDto operatorDto) { ClaimsIdentity _claim = null; var _operator = await this._auow.OperatorManager.FindAsync(operatorDto.Email, operatorDto.Password); if (_operator != null) { _claim = await this._auow.OperatorManager.CreateIdentityAsync(_operator, DefaultAuthenticationTypes.ApplicationCookie); } return(_claim); }
public async Task <IActionResult> GetBy([FromRoute] int code) { OperatorDto operatorDto = await this.operatorService.GetByCode(code); if (operatorDto != null) { return(this.Ok(operatorDto)); } return(this.NotFound("A operator w/ the given code was not found")); }
public void AddOperator(OperatorDto operatorDto) { string code = AuthManager.GetCurrentUser().Code; var businessman = businessmanRepository.FindAll(x => x.Code == code).SingleOrDefault(); Operator op = new Operator(); op.Account = operatorDto.Account; op.OperatorState = EnumOperatorState.Normal; op.Password = operatorDto.Password; op.Phone = operatorDto.Phone; op.Realname = operatorDto.Realname; op.Tel = operatorDto.Tel; businessman.NewOperator(op); unitOfWorkRepository.PersistUpdateOf(businessman); unitOfWork.Commit(); }
public async Task <ActionResult> OperatorRegister(OperatorDto operatorDto) { if (!ModelState.IsValid) { return(View(operatorDto)); } var sucsess = await UserService.Create(operatorDto); if (sucsess) { return(RedirectToAction("GetFaculty", "Faculty", new { area = string.Empty })); } return(View(operatorDto)); }
public static OperatorDto ToDto(this DataAccess.Models.Operator item) { OperatorDto dto = null; if (item != null) { dto = new OperatorDto { Id = item.Id, FirstName = item.FirstName, LastName = item.LastName, Mobile = item.Mobile, Email = item.Email }; } return(dto); }
public void Create_Operator_CorrectOperatorName() { var name = "name"; var _operator = new Operator() { Name = name }; var operatorDto = new OperatorDto() { Name = name }; _unitOfWorkMock.Setup(uof => uof.OperatorGenericRepository.Create(_operator)); _sut.Create(operatorDto); Assert.Equal(name, _operator.Name); }
public static OperatorDto ToOperator(this UserDto user) { OperatorDto dto = null; if (user != null) { dto = new OperatorDto { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, Mobile = user.Mobile, Phone = user.Mobile }; } return(dto); }
private void ExecuteActiveCommand(OperatorDto param) { IsBusy = true; Action action = () => CommunicateManager.Invoke <IBusinessmanService>(p => { p.ModifyOperatorState(param.Account); Refresh(param); }, UIManager.ShowErr); Task.Factory.StartNew(action).ContinueWith(task => { DispatcherHelper.UIDispatcher.Invoke(new Action(() => { IsBusy = false; ActiveCommand.RaiseCanExecuteChanged(); })); }); }
internal static void ShowOperatorDialog(OperatorDto operatorDto, Action <bool?> call) { //DispatcherHelper.UIDispatcher.Invoke(new Action(() => // { var addOperator = new AddOperator(); var vm = operatorDto != null ? new AddOperatorViewModel(operatorDto) : new AddOperatorViewModel(); addOperator.DataContext = vm; addOperator.Owner = Application.Current.MainWindow; var dialogResult = addOperator.ShowDialog(); if (call != null) { call(dialogResult); } addOperator.DataContext = null; //})); }
/// <summary> /// 刷新一条数据 /// </summary> private void Refresh(OperatorDto model) { var oldData = OpList.FirstOrDefault(m => m.Id == model.Id); if (oldData == null) { return; } CommunicateManager.Invoke <IBusinessmanService>(p => { var temp = p.GetAllOperators(model.Realname, model.Account, null); //分开写方便调试 if (temp == null || temp.Count <= 0) { return; } var index = OpList.IndexOf(oldData); if (index < 0) { return; } var newData = temp.FirstOrDefault(m => m.Id == model.Id); if (newData == null) { return; } Action setAction = () => { OpList[index] = newData; }; DispatcherHelper.UIDispatcher.Invoke(setAction); }, UIManager.ShowErr); }
public ActionResult <OperatorDto> Post([FromBody] OperatorDto dto) { return(_operatorService.Create(dto)); }
public AddOperatorViewModel() { Operator = new OperatorDto(); }
public AddOperatorViewModel(OperatorDto operatorDto) { InitlizeEdit(operatorDto); }
private static Operator GetOperator(OperatorDto dto) { return(DefinedOperators.All.FirstOrDefault(x => x.Name == dto.Name && x.Type == dto.Type)); }
private bool CanExecuteResetPswCommand(OperatorDto obj) { return(true); }