示例#1
0
 public void RepositoryAdd()
 {
     repository.Insert(new Dog
     {
         Des = new Des {
             SortNum = 3
         },
         DataStatus = Status.Deleted,
         Title      = "哈巴狗1",
         Type       = "美国",
         DogHistory = new List <DogHistory>(),
         Foods      = new string[] { }
     });
 }
示例#2
0
        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"));
        }
示例#3
0
 public ActionResult Create(Product entity)
 {
     entity.UserInfoId       = UserId;
     entity.UserInfoUserName = Lind.DDD.Authorization.CurrentUser.UserName;
     productRepository.Insert(entity);
     return(RedirectToAction("Index"));
 }
示例#4
0
        public ActionResult Register(UserInfo entity)
        {
            entity.UserExtension = new UserExtension
            {
                School   = "不用填",
                NickName = entity.RealName,
            };
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "请把表单填写完整!");
                return(View());
            }
            if (!entity.Password_TruePassword())
            {
                ModelState.AddModelError("", "两次密码需要一致!");
                return(View());
            }
            else if (entity.IsExistUser())
            {
                ModelState.AddModelError("", "用户已经存在!");
                return(View());
            }
            else
            {
                try
                {
                    entity.Role     = UserRole.User;
                    entity.Password = entity.Md5Password();
                    userRepository.Insert(entity);

                    //送的虚拟货币
                    userAccountRepository.Insert(new UserAccount
                    {
                        UserInfoId        = entity.Id,
                        FreezeMoney       = 0,
                        Money             = 50,
                        TotalMoney        = 50,
                        UserAccountDetail = new List <UserAccountDetail>()
                        {
                            new UserAccountDetail {
                                Memo  = "新用户注册送50元!",
                                Money = 50, Type = UserAccountDetailType.In
                            }
                        }
                    });

                    //模拟登陆
                    CurrentUser.Serialize(entity.Id.ToString(), entity.UserName, extInfo: "50", role: entity.Role.ToString());
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View());
                }

                return(RedirectToAction("Index", "Shop"));
            }
        }
 public ActionResult Create(Evaluation entity)
 {
     if (ModelState.IsValid)
     {
         evaluationRepository.Insert(entity);
         return(RedirectToAction("Index"));
     }
     else
     {
         ModelState.AddModelError("", "请把表单填写完整...");
         return(View(entity));
     }
 }
示例#6
0
        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"));
        }
示例#7
0
 public ActionResult Create(UserInfo entity)
 {
     entity.UserExtension = new UserExtension
     {
         School   = "北京大学",
         NickName = entity.RealName,
     };
     if (!entity.Password_TruePassword())
     {
         ModelState.AddModelError("", "两次密码需要一致!");
         return(View());
     }
     else if (entity.IsExistUser())
     {
         ModelState.AddModelError("", "用户已经存在!");
         return(View());
     }
     else
     {
         entity.Password = entity.Md5Password();
         userRepository.Insert(entity);
         return(RedirectToAction("Index"));
     }
 }