public IHttpActionResult Register([FromBody] ResourceTrackerRegisterModel model) { if (ModelState.IsValid) { var userModel = _userCredential.GetByLoginID(model.PhoneNumber, UserType.ResourceTrackerAdmin); if (userModel != null) { return(BadRequest("This mobile number already exists.")); } var password = CryptographyHelper.CreateMD5Hash(model.Password); var response = _userCredential.Save(new Common.Models.UserCredentialModel { FullName = model.UserFullName, UserTypeId = (int)UserType.ResourceTrackerAdmin, Email = model.Email, ContactNo = model.PhoneNumber, LoginID = model.PhoneNumber, IsActive = true, Password = password }); return(Ok(response)); } return(BadRequest("Invalid model.")); }
private ResponseModel CreateUser(EmployeeRegistrationModel model) { var userModel = _userCredential.GetByLoginID(model.PhoneNumber, UserType.ResourceTrackerAdmin); if (userModel != null) { return new ResponseModel { Message = "This mobile number already exists." } } ; var p = GeneratePassword(); var password = CryptographyHelper.CreateMD5Hash(p); var response = _userCredential.Save(new UserCredentialModel { FullName = model.UserFullName, UserTypeId = (int)UserType.ResourceTrackerUser, Email = model.Email, ContactNo = model.PhoneNumber, LoginID = model.PhoneNumber, IsActive = true, Password = password }); if (response.Success) { Task.Run(() => SendMailToUser(model.Email, model.PhoneNumber, p)); } return(new ResponseModel { Success = response.Success, Message = response.Success?p:string.Empty, ReturnCode = response.ReturnCode }); }