/// <summary> /// Used to register User /// </summary> /// <param name="registrationModel"></param> /// <returns></returns> public int RegisterUser(RegistrationModel registrationModel) { try { using (var tde = new TimeDifferenceEntities()) { var userData = new User { Email = registrationModel.Email, UserName = registrationModel.UserName, Password = registrationModel.Password, RoleId = Convert.ToInt32(registrationModel.RoleId), IsActive = true }; tde.Users.Add(userData); tde.SaveChanges(); return userData.Id; } } catch (Exception ex) { throw new Exception("Exception Occured", ex.InnerException); } }
/// <summary> /// Used to register User /// </summary> /// <param name="registrationModel"></param> /// <returns></returns> public int RegisterUser(RegistrationModel registrationModel) { registrationModel.RoleId = UserRole.User; registrationModel.Email = registrationModel.Email.ToLower(); registrationModel.Password = new EncryptionHelper().Encrypt(registrationModel.Password); return new Data.UserMethods().RegisterUser(registrationModel); }
public int RegisterUser(RegistrationModel registrationModel) { try { if (IsEmailExist(registrationModel.Email)) throw new HttpResponseException(HttpStatusCode.BadRequest); return new Business.UserMethods().RegisterUser(registrationModel); } catch (HttpResponseException ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(string.Format("Email ID already exist.")), ReasonPhrase = "Bad Request" }); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ServiceUnavailable) { Content = new StringContent(string.Format("Service is currently unavailable.")), ReasonPhrase = "Service Unavailable " }); } }