public async Task <ActionResult> Add(RegisterRepresentativeUser representativeUserModel) { if (await _representativeUserService.IsExistByEmail(representativeUserModel.Email)) { ModelState.AddModelError("", "پست الکترونیکی وارد شده قبلا در سیستم ثبت شده است."); return(this.JsonValidationErrors()); } var representativeUser = new DomainClasses.RepresentativeUser { 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.Add(representativeUser); await _dbContext.SaveChangesAsync(); return(Json(representativeUser.Id)); }
public async Task <ActionResult> IsExistByEmail(string term) { return(Json(await _representativeUserService.IsExistByEmail(term), JsonRequestBehavior.AllowGet)); }