public object UsersmSignup(SmSignUp smSignUp) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ApiResponse rs = users.Createsm(smSignUp); return(rs); }
public ApiResponse Createsm(SmSignUp smSignUp) { try { var chkUser = (from s in entity.TB_ECOMM_USERS where s.USER_EMAIL == smSignUp.USER_EMAIL || s.USER_NAME == smSignUp.USER_NAME select s).FirstOrDefault(); if (chkUser == null) { TB_ECOMM_USERS EL = new TB_ECOMM_USERS(); if (EL.USER_ID == 0) { var keyNew = HelperMethods.GeneratePassword(10); EL.USER_NAME = smSignUp.USER_NAME; EL.USER_EMAIL = smSignUp.USER_EMAIL; EL.USER_ID = smSignUp.USER_SID; EL.GENDER = smSignUp.GENDER; //var User_Password = HelperMethods.EncodePassword(signUp.USER_PASSWORD, keyNew); //EL.USER_PASSWORD = User_Password; //EL.PASSWORD_SALT = keyNew; entity.TB_ECOMM_USERS.Add(EL); entity.SaveChanges(); return(new ApiResponse { Status = "Success", Message = "User SuccessFully Saved." }); } } else { return new ApiResponse { Status = "Error", Message = "User Already Exist!!!" } }; } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { return(new ApiResponse { Status = "Error", Message = validationError.ErrorMessage }); } } } return(new ApiResponse { Status = "Error", Message = "Invalid Data." }); }