public User RegisterManualAlumni(ManualUserRegVm userDetails) { lock (_regSync) { if (string.IsNullOrEmpty(userDetails.Email)) { var count = _db.Users.ToList().Last().UserId + 1; userDetails.Email = "unknown_" + count + "@nitcaa.com"; } _userService.ValidateEmailUnique(userDetails.Email); var user = userDetails.GetUserEntity(); user.HashedPassword = _hashService.CreateHash(Constants.DefaultPassword); user.AccountStatus = UserRegisterStatus.Approved; user.EmailConfirmedOn = DateTime.UtcNow; // For Dummy Logging in user.CreateType = UserCreateTypes.Admin; user.UserRoles.Add(new UserRole { RoleType = UserRoleType.Alumni }); UpdateCourseDetails(userDetails.Batch, userDetails.BranchId, user); _db.Users.Add(user); _db.SaveChanges(); AddUserLog(user.UserId, "User Created Manually"); return(user); } }
public JsonResult AddUser(ManualUserRegVm model) { if (ModelState.IsValid) { using (var srv = new RegisterService()) { srv.RegisterManualAlumni(model); } } return(GetErrorMsgJSON()); }