Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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 "
                });
            }
        }