public ActionResult LoginExisting(PersonalInfoVM model) { var cmr = db.Login(model); if (cmr == null) { ViewBag.LoginError = true; model.Countries = db.GetCountries(); foreach (var modelValue in ModelState.Values) { modelValue.Errors.Clear(); } return(View("PersonalInfo", model)); } else { Session["CustomerId"] = cmr.CustomerId; Session["CustomerName"] = cmr.CustomerName; Session["IsBP"] = cmr.BPId.HasValue; if (cmr.BPId.HasValue && Session["Cart"] != null) { CartVM cart = (CartVM)Session["Cart"]; foreach (var good in cart.Products) { good.Price = good.Price * 0.77M; } } } return(RedirectToAction("checkout")); }
public ActionResult Edit(int?id) { try { if (Session["EmployeeId"] != null) { if (id == null) { return(new HttpStatusCodeResult(400)); } Employee e = s.GetEmployee((int)id); if (e == null) { return(new HttpStatusCodeResult(404)); } PersonalInfoVM vm = new PersonalInfoVM() { Employee = e, }; return(View(vm)); } else { return(RedirectToAction("Index", "Home")); } } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Recipes", "Edit"))); } }
public OperationResult EditPersionalInfo(PersonalInfoVM vm) { try { var user = _userReps.FirstOrDefault(c => c.Id == vm.Id && c.Enabled == true); if (user == null) { throw new Exception(); } if (user.Password != EncryptionHelper.GetMd5Hash(vm.Password.Trim())) { return(new OperationResult(OperationResultType.Error, "旧密码不正确。")); } if (!vm.NewPassword.Equals(vm.ComfirmPassword)) { return(new OperationResult(OperationResultType.Error, "两次输入的新密码不相同,请重新输入")); } var pwd = EncryptionHelper.GetMd5Hash(vm.NewPassword.Trim()); _userReps.Update(c => c.Id == vm.Id, u => new Users() { Password = pwd, UpdateDate = DateTime.Now }); return(new OperationResult(OperationResultType.Success, "密码修改成功!")); } catch { return(new OperationResult(OperationResultType.Error, "密码修改失败!")); } }
public ActionResult RegisterNewCustomer(PersonalInfoVM model) { if (!ModelState.IsValid) { model.Countries = db.GetCountries(); return(View("PersonalInfo", model)); } if (db.CustomerExists(model.CustomerEmail)) { ViewBag.EmailUsed = true; model.Countries = db.GetCountries(); return(View("PersonalInfo", model)); } var pass = model.Password; var customerData = db.CreateCustomerWithPassword(model); string content = System.IO.File.ReadAllText(Server.MapPath("/Mails/newuser.txt")); content = content.Replace("{username}", model.CustomerEmail); content = content.Replace("{password}", pass); Parallel.Invoke(() => { Common.Tools.Mailer.SendMailSpecific(content, model.CustomerEmail, "Your user is created"); }); Session["CustomerId"] = customerData; Session["CustomerName"] = model.CustomerName; return(RedirectToAction("checkout")); }
public ActionResult EditPersionalInfo(PersonalInfoVM vm) { if (!ModelState.IsValid) { return(Json(new OperationResult(OperationResultType.ParamError, "参数错误,请重新检查输入"))); } var result = _userService.EditPersionalInfo(vm); return(Json(result)); }
public ActionResult PersonalInfo() { if (Session["CustomerId"] != null) { return(RedirectToAction("checkout")); } PersonalInfoVM model = new PersonalInfoVM(); model.Countries = db.GetCountries(); return(View(model)); }
public CustomerVM Login(PersonalInfoVM model) { var md5 = Common.Tools.MD5.ConvertToMD5(model.Password); var cmr = db.Customers.FirstOrDefault(c => c.Username == model.CustomerEmail && c.Password == md5); if (cmr == null) { return(null); } else { return(_map.Map <CustomerVM>(cmr)); } }
public ActionResult Edit(PersonalInfoVM vm) { try { if (s.ModifyPersonalInfo(vm.Employee)) { vm.IsSuccessful = true; return(View(vm)); } return(View(vm)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Recipes", "Edit"))); } }
public int CreateCustomerWithPassword(PersonalInfoVM model) { Customer c = new Customer() { Address = "", City = "", CountryId = model.BillingCountryId, CustomerName = model.CustomerName, Password = MD5.ConvertToMD5(model.Password), Username = model.CustomerEmail }; db.Customers.Add(c); db.SaveChanges(); return(c.CustomerId); }
public ActionResult EditPersionalInfo() { string userId = ((System.Web.Security.FormsIdentity)(HttpContext.User.Identity)).Ticket.UserData; int id = Convert.ToInt32(userId); var user = _userService.GetUser(c => c.Id == id); if (user == null) { return(PartialView("PersonalInfo", new PersonalInfoVM())); } int phone; int.TryParse(user.Phone, out phone); var model = new PersonalInfoVM() { Id = user.Id }; return(PartialView("PersonalInfo", model)); }
public void SavePersonalInfo(PersonalInfoVM personalInfo) { throw new NotImplementedException(); }