public JsonResult CreateAjax(tUser user) { user.DateAdded = DateTime.Now; if (ModelState.IsValid) { _userRepository.InsertOrUpdate(user); return(Json(new { objectAddedName = user.UserName, valid = true, Message = "User was added Succesfully" })); } else { return(Json(new { objectAddedName = "", valid = false, Message = "Fill All Fields please" })); } }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { _UserRep = BootStrapper.GetCurrentUserRepository(); ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if ((RequiresUniqueEmail && (GetUserNameByEmail(email) != String.Empty))) { status = MembershipCreateStatus.DuplicateEmail; return null; } MembershipUser membershipUser = GetUser(username, false); if (membershipUser == null) { System.DateTime createDate = DateTime.Now; tUser user = new tUser(); user.UserName = username; user.Password = password; user.UserName = email; user.Approved = isApproved; //user.Address = ""; //user.AdSoyad = ""; //user.Avatar = ""; //user.BirthDate = new DateTime(1900, 1, 1); //user.CellNo = ""; //user.City = ""; user.DateAdded = DateTime.Now; user.LastLoginDate = DateTime.Now; //user.Role = "User"; //user.Semt = ""; //user.TellNo = ""; //user.UserStatus = (int)B2B.Core.Enums.enmUserStatus.Active; user.IDRole = (int) Enums.enmRoles.User; try { _UserRep.InsertOrUpdate(user); int result = 1; if (result > 0) { _UserRep.Save(); status = MembershipCreateStatus.Success; } else { status = MembershipCreateStatus.UserRejected; } } catch (Exception err) { //Add exception handling here. status = MembershipCreateStatus.ProviderError; } return GetUser(username, false); } else { status = MembershipCreateStatus.DuplicateUserName; } return null; }