public async Task<ActionResult> Edit(RegisterRepresentativeUser representativeUserModel) { if (!await _representativeUserService.CanEditEmail(representativeUserModel.Id, representativeUserModel.Email)) { ModelState.AddModelError("", "پست الکترونیکی وارد شده قبلا در سیستم ثبت شده است."); return this.JsonValidationErrors(); } var representativeUser = new DomainClasses.RepresentativeUser { Id = representativeUserModel.Id, Email = representativeUserModel.Email, FirstName = representativeUserModel.FirstName, LastName = representativeUserModel.LastName, FatherName = representativeUserModel.FatherName, MobileNumber = representativeUserModel.MobileNumber, NationalCode = representativeUserModel.NationalCode, UniversityId = representativeUserModel.UniversityId, Password = EncryptionHelper.Encrypt( !string.IsNullOrEmpty(representativeUserModel.Password) ? representativeUserModel.Password : CreatePassword(6), EncryptionHelper.Key ), }; _representativeUserService.Edit(representativeUser); await _dbContext.SaveChangesAsync(); return Json(representativeUser.Id); }
public virtual async Task<ActionResult> Index(RegisterRepresentativeUser representativeUser) { _representativeUserService.Add(new DomainClasses.RepresentativeUser() { FirstName = representativeUser.FirstName, LastName = representativeUser.LastName, FatherName = representativeUser.FatherName, MobileNumber = representativeUser.MobileNumber, NationalCode = representativeUser.NationalCode, Email = representativeUser.Email, UniversityId = representativeUser.UniversityId }); await _dbContext.SaveChangesAsync(); return View(); }