public void Handle(OrderDispatchedEvent evt) { //发货通知 var user = repository.Find(evt.UserId); MessageFactory.GetService(MessageType.Email).Send(user.Email, "发货通知", "卖家已经为您发货了,请注意查收,订单号:" + evt.OrderId + ",时间:" + evt.EventTime); }
/// <summary> /// 用户设置 /// </summary> /// <returns></returns> public ActionResult Setting() { int userid; int.TryParse(CurrentUser.UserID, out userid); return(View(userRepository.Find(userid))); }
/// <summary> /// 购买 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Do(int id) { ViewBag.Money = (userAccountRepository.Find(i => i.UserInfoId == UserId) ?? new UserAccount()).Money; return(View(productRepository.GetModel() .Include(i => i.Category) .FirstOrDefault(i => i.Id == id))); }
public ActionResult Edit(int id) { var account = userAccountRepository.Find(i => i.UserInfoId == id); ViewBag.AccountMoney = account == null ? 0 : account.Money; return(View(userRepository.GetModel() .Include(i => i.UserExtension) .Include(i => i.UserAccount) .FirstOrDefault(i => i.Id == id))); }
public string DeptDropdownList2(int?parentId) { StringBuilder sbr = new StringBuilder(); var dept = departmentsRepository.Find(i => i.Level == 0); if (parentId.HasValue) { dept = departmentsRepository.Find(i => i.Id == parentId); GetSelectList(dept, sbr); } return(sbr.ToString()); }
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 Index(FormCollection form) { int productId; int.TryParse(form["Id"], out productId); int saleCount; int.TryParse(form["SaleCount"], out saleCount); var product = productRepository.Find(productId); var orderDetail = new OrderDetail() { Price = product.Price, ProductId = productId, ProductName = product.Name, SaleCount = saleCount, UserInfoId = product.UserInfoId, UserInfoUserName = product.UserInfoUserName, }; var order = new OrderInfo { OrderStatus = OrderStatus.Created, OrderDetail = new List <OrderDetail>() { orderDetail }, UserInfoId = UserId, UserInfoName = CurrentUser.UserName }; orderInfoRepository.Insert(order); return(RedirectToAction("MyOrder", "User")); }
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)); }
public ActionResult Login(string returnUrl, FormCollection form) { var entity = new UserInfo { UserName = form["username"], Password = form["password"] }.Login(); if (entity == null) { ModelState.AddModelError("", "用户名密码不正确"); return(View()); } CurrentUser.Serialize( entity.Id.ToString(), entity.UserName, extInfo: userAccountRepository.Find(i => i.UserInfoId == entity.Id).Money.ToString(), role: entity.Role.ToString()); if (string.IsNullOrWhiteSpace(returnUrl)) { return(RedirectToAction("Index", "User")); } else { return(Redirect(returnUrl)); } }
/// <summary> /// 用户登陆 /// </summary> /// <returns></returns> public UserInfo Login() { userRepository = ServiceLocator.Instance.GetService <IExtensionRepository <UserInfo> >(); string md5 = Md5Password(); return(userRepository.Find(i => i.UserName == this.UserName && i.Password == md5)); }
/// <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 RepositoryEdit() { var dog = repository.Find(i => i.Id == "58520492ebb91a2e74c6645a"); 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(dog);//没有被赋值的字段被null,建议先获取再更新 }
public ActionResult Edit(UserInfo entity) { decimal money; decimal.TryParse(Request.Form["AccountMoney"], out money); //UoW机制 var account = userAccountRepository.Find(i => i.UserInfoId == entity.Id); account.Money = money; unitOfWork.RegisterChangeded(account, SqlType.Update, userAccountRepository); entity.UserExtension = null; unitOfWork.RegisterChangeded(entity, SqlType.Update, userRepository); var userExtension = userExtRepository.Find(entity.Id); userExtension.NickName = Request.Form["UserExtension.NickName"]; userExtension.School = Request.Form["UserExtension.School"]; unitOfWork.RegisterChangeded(userExtension, SqlType.Update, userExtRepository); unitOfWork.Commit(); return(RedirectToAction("Index")); }
/// <summary> /// 产品详细 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Details(int id) { return(View(productRepository.Find(id))); }