private User FillUserByViewModel(RegisterVeiwModel register) { var user = new User() { Status = 1, Roles = "User", Wallet = 0, Username = register.Username.ToLower().Trim(), Password = register.Password.Encrypt(), Dateofbirth = register.PersianDateofbirth.ToMiladiDate(), Biography = register.Biography, Email = register.Email, Gender = register.Gender, Location = register.Location, Name = register.Name, Phone = register.Phone, PersianDateofbirth = register.PersianDateofbirth }; if (register.leafletViewwModel.Lat != null && register.leafletViewwModel.Lng != null) { string strPointWellKnownText = string.Format(CultureInfo.InvariantCulture.NumberFormat, "POINT({0} {1})", register.leafletViewwModel.Lng, register.leafletViewwModel.Lat); DbGeography oDbGeography = DbGeography.PointFromText (pointWellKnownText: strPointWellKnownText, coordinateSystemId: 4326); user.GeoLocation = oDbGeography; } return(user); }
//[ReCaptcha] public ActionResult Register(RegisterVeiwModel user, string foo) { if (!ModelState.IsValid) { return(View(user)); } if (_accountService.Register(user)) { return(RedirectToAction(actionName: "Login", controllerName: "Account")); } return(View(user)); }
public bool Register(RegisterVeiwModel register) { if (!_userRepository.Select(p => p.Username == register.Username.ToLower().Trim()).Any()) { return(false); } var user = FillUserByViewModel(register); if (_userRepository.Add(user)) { return(true); } return(false); }