public ActionResult ModifyPassword(ChangePasswordModel model) { if (ModelState.IsValid) { // 在某些出错情况下,ChangePassword 将引发异常, // 而不是返回 false。 bool changePasswordSucceeded = false; var oldpassword = Lind.DDD.Utils.Encryptor.Utility.EncryptString(model.OldPassword, Utils.Encryptor.Utility.EncryptorType.MD5); var old = userRepository.Find(i => i.UserName == CurrentUser.UserName && i.Password == oldpassword); if (old != null) { old.Password = Lind.DDD.Utils.Encryptor.Utility.EncryptString(model.NewPassword, Utils.Encryptor.Utility.EncryptorType.MD5); userRepository.Update(old); changePasswordSucceeded = true; } if (changePasswordSucceeded) { return(RedirectToAction("ChangePasswordSuccess")); } else { ModelState.AddModelError("", "当前密码不正确或新密码无效。"); } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(View(model)); }
/// <summary> /// 买家付款 /// </summary> /// <returns></returns> public ActionResult Paid(int id) { //写日志 Lind.DDD.Logger.LoggerFactory.Instance.Logger_Info("买家付款,订单号:" + id); #region 更新到数据库 var entity = orderInfoRepository.Find(id); entity.OrderStatus = OrderStatus.Paid; orderInfoRepository.Update(entity); #endregion //写队列 //Lind.DDD.CachingQueue.QueueManager.Instance.Push(Utils.SerializeMemoryHelper.SerializeToBinary("买家付款,订单号:" + id)); //事件总线 entity.Paid(); return(RedirectToAction("OrderList", "Shop")); }
public void RepositoryEditList() { var dogList = repository.GetModel().ToList(); dogList.ForEach(dog => { dog.Type = "ddud"; dog.Foods = new string[] { "1", "2", "3" }; dog.AddressHistory = new List <Adderss>(); dog.AddressHistory.Add(new Adderss("zzl", "lr", "123")); dog.AddressHistory.Add(new Adderss("zzl2", "lr2", "1232")); dog.AddressHistory.Add(new Adderss("zzl3", "lr3", "1233")); dog.DogHistory = new List <DogHistory>(); dog.DogHistory.Add(new DogHistory { SortNum = 3, HistoryName = "大毛", IsHealth = true, Foods = new string[] { "肉" }, AddressList = new List <Adderss> { new Adderss("china", "beijing", "fangshan"), new Adderss("china", "shanghai", "pujiang") } }); dog.DogHistory.Add(new DogHistory { SortNum = 1, HistoryName = "毛仔", IsHealth = true, Foods = new string[] { "饲料" }, AddressList = new List <Adderss> { new Adderss("usa", "jiazhou", "no.1") } }); dog.Des.Worker = new string[] { "engineer", "coder" }; dog.DefaultAdderss = new Adderss("1", "2", "3"); dog.Des.Address = new List <Adderss> { new Adderss("beijing", "fangshan", "liangxiang", new string[] { "zhaojiaogan", "Road100", "No.300" }), new Adderss("美国", "加州", "1区", new string[] { "Road1", "Room4", "No.1" }), }; }); repository.Update(dogList);//没有被赋值的字段被null,建议先获取再更新 }
public ActionResult Do(FormCollection form) { var orderDetail = new List <OrderDetail>(); foreach (var id in form["Id"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { int productId; int.TryParse(id, out productId); var product = productRepository.Find(productId); orderDetail.Add(new OrderDetail() { Price = product.Price, ProductId = productId, ProductName = product.Name, SaleCount = 1, UserInfoId = product.UserInfoId, UserInfoUserName = product.UserInfoUserName, StartTime = DateTime.Now, EndTime = DateTime.Now.AddYears(1) }); } var order = new OrderInfo { OrderStatus = OrderStatus.Created, OrderDetail = orderDetail, UserInfoId = Convert.ToInt32(CurrentUser.UserID), UserInfoName = CurrentUser.UserName }; orderInfoRepository.Insert(order); var account = userAccountRepository.Find(i => i.UserInfoId == UserId); account.Money = account.Money - order.OrderPrice < 0 ? 0 : account.Money - order.OrderPrice; userAccountRepository.Update(account); CurrentUser.Serialize( CurrentUser.UserID, CurrentUser.UserName, extInfo: account.Money.ToString(), role: CurrentUser.Role); CookieHelper.Remove("MyCart"); return(RedirectToAction("OrderSuccess")); }
public ActionResult Edit(int id, Product entity) { productRepository.Update(entity); return(RedirectToAction("Index")); }