Exemplo n.º 1
0
        public ActionResult OrderDetail(int orderId)
        {
            var order    = orderService.GetOrderByOrderId(orderId);
            var orderDTO = new ViewModelOrder()
            {
                OrderId          = order.OrderId,
                CustomerId       = order.CustomerId,
                DeliveryName     = order.DeliveryName,
                DetailAddress    = order.DetailAddress,
                Express          = order.Express,
                GoodsId          = order.GoodsId,
                GoodsName        = order.GoodsName,
                OrderGoodsNumber = order.OrderGoodsNumber,
                OrderStatus      = order.OrderStatus,
                OrderTime        = order.OrderTime,
                Price            = order.Price,
                Province         = order.Province,
                SellerMessage    = order.SellerMessage,
                Street           = order.Street,
                TelNum           = order.TelNum,
                VersionId        = order.VersionId,
                VersionName      = order.VersionName,
                Area             = order.Area,
            };

            return(View(orderDTO));
        }
Exemplo n.º 2
0
        public IActionResult Get(string userName)
        {
            var entiys = OrderBLL.GetEntiysInclude(
                whereExpressions: u => u.User.UserName.Equals(userName),
                expressions: new System.Linq.Expressions.Expression <Func <Order, object> >[]
                { u => u.Commodity })
                         .OrderByDescending(u => u.CreateDateTime)
                         .IgnoreQueryFilters(); //IgnoreQueryFilters()取消全局过滤

            //OrderBLL.GetALLEntiyByWhere<Order>(u => u.User.UserName.Equals(userName)).IgnoreQueryFilters();  //暂时有问题,导航属性Commodity查不出,暂时不知道原因

            var list = new List <ViewModelOrder>();

            foreach (var item in entiys)
            {
                var resultModel = new ViewModelOrder
                {
                    UserName     = item.User.UserName,
                    SendUserName = item.SendUser.UserName,
                    OrderNumber  = item.OrderNumber,
                    OrderState   = item.OrderState,
                    Code         = item.Code,
                };
                list.Add(resultModel);
            }
            //获取订单的action
            return(new JsonResult(list));
        }
Exemplo n.º 3
0
        public IActionResult Food()
        {
            var model = new ViewModelOrder();

            model.DishList     = _context.Matratt.ToList();
            model.CategoryList = _context.MatrattTyp.ToList();
            return(View(model));
        }
Exemplo n.º 4
0
        // GET: /<controller>/
        public IActionResult ViewFood()
        {
            ViewModelOrder model = new ViewModelOrder();

            model.ListOfMatratt = _context.Matratt.ToList();
            model.ListOfTyper   = _context.MatrattTyp.ToList();
            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult PlaceOrderByShoppingCar()
        {
            var customerId        = (int)Session["CustomerId"];
            var form              = Request.Form;
            var goodsIds          = form.GetValues("GoodsId");
            var versionIds        = form.GetValues("VersionId");
            var orderGoodsNumbers = form.GetValues("OrderGoodsNumber");
            var sellerMessage     = form.GetValues("SellerMessage").First();
            var address           = new DeliveryAddress();
            var deliveryAddressId = form.GetValues("DeliveryAddressId").First();

            if (deliveryAddressId != "")
            {
                address = userService.GetDeliveryAddressByAddressId(int.Parse(deliveryAddressId));
            }
            else
            {
                address = userService.GetDeliveryAddressByCustomerId(customerId);
            }
            var orderListDTO = new List <ViewModelOrder>();

            for (int i = 0; i < goodsIds.Length; i++)
            {
                var    version   = goodsService.GetVersionByVersionId(int.Parse(versionIds[i]));
                var    goods     = goodsService.GetGoodsByGoodsId(int.Parse(goodsIds[i]));
                Orders saveOrder = new Orders
                {
                    CustomerId       = customerId,
                    GoodsId          = goods.GoodsId,
                    GoodsName        = goods.GoodsName,
                    OrderGoodsNumber = int.Parse(orderGoodsNumbers[i]),
                    VersionName      = version.VersionName,
                    VersionId        = int.Parse(versionIds[i]),
                    WarehouseId      = version.WarehouseId,
                    Area             = address.Area,
                    DeliveryName     = address.DeliveryName,
                    DetailAddress    = address.DetailAddress,
                    Province         = address.Province,
                    TelNum           = address.TelNum,
                    Street           = address.Street,

                    OrderTime   = DateTime.Now,
                    Price       = version.Price,
                    OrderStatus = 0,
                    //Express = order.Express,
                    SellerMessage = sellerMessage,
                };
                orderService.SaveOrder(saveOrder);
                ViewModelOrder orderDTO = new ViewModelOrder
                {
                    OrderId = saveOrder.OrderId
                };
                orderListDTO.Add(orderDTO);
            }
            return(PartialView("PayAll", orderListDTO));
        }
Exemplo n.º 6
0
        public ActionResult PlaceOrder(ViewModelOrder order, ViewModelDeliveryAddress deliveryAddress)
        {
            var customerId = (int)Session["CustomerId"];
            var address    = userService.GetDeliveryAddressByAddressId(deliveryAddress.DeliveryAddressId);
            var version    = goodsService.GetVersionByVersionId(order.VersionId);
            var goods      = goodsService.GetGoodsByGoodsId(order.GoodsId);

            if (address == null)
            {
                var defaultAddress = userService.GetDeliveryAddressByCustomerId(customerId);
                if (defaultAddress == null)
                {
                    TempData["TipModify"] = "请添加收货地址!!!";
                    return(Redirect("/FrontCustomer/MyMall"));
                }
                address = defaultAddress;
            }
            Orders saveOrder = new Orders
            {
                CustomerId       = customerId,
                GoodsId          = goods.GoodsId,
                GoodsName        = goods.GoodsName,
                OrderGoodsNumber = order.OrderGoodsNumber,
                VersionName      = version.VersionName,
                VersionId        = order.VersionId,
                WarehouseId      = version.WarehouseId,
                Area             = address.Area,
                DeliveryName     = address.DeliveryName,
                DetailAddress    = address.DetailAddress,
                Province         = address.Province,
                TelNum           = address.TelNum,
                Street           = address.Street,

                OrderTime     = DateTime.Now,
                Price         = version.Price,
                OrderStatus   = 0,
                Express       = order.Express,
                SellerMessage = order.SellerMessage,
            };

            orderService.SaveOrder(saveOrder);
            ViewModelOrder orderDTO = new ViewModelOrder
            {
                OrderId = saveOrder.OrderId
            };

            return(PartialView("Pay", orderDTO));
        }
Exemplo n.º 7
0
        public async Task <List <ViewModelOrder> > Get()
        {
            _logger.LogInformation("Get items");
            var orderList = await _orderRepo.GetAllOrders();

            var modelOrders = new List <ViewModelOrder>();

            foreach (var order in orderList)
            {
                var client = await _clientRepo.GetClientById(order.ClientId);

                var kadett = await _kadettRepo.GetKadettById(order.KadettId);

                var modelTickets = new List <ViewModelTicket>();
                var orderTickets = await _ticketOrderRepo.GetTicketOrderByOrderId(order.Id);

                foreach (var orderTicket in orderTickets)
                {
                    var tickets = await _ticketRepo.GetTicketById(orderTicket.TicketId);

                    var vmTicket = new ViewModelTicket()
                    {
                        Type     = tickets.Type,
                        Quantity = orderTicket.Quantity,
                        Day      = orderTicket.Day
                    };
                    modelTickets.Add(vmTicket);
                }

                var vm = new ViewModelOrder
                {
                    Email           = client.Email,
                    Phone           = client.Phone,
                    Bemerkung       = order.Bemerkung,
                    ClientFirstName = client.FirstName,
                    ClientLastName  = client.LastName,
                    Tickets         = modelTickets,
                    KadettFirstName = kadett.FirstName,
                    KadettLastName  = kadett.LastName,
                    KadettInKader   = kadett.KadettInKader
                };
                modelOrders.Add(vm);
            }


            return(modelOrders);
        }
Exemplo n.º 8
0
        public ActionResult PlaceOrder(int goodsId, int orderGoodsNumber, int VersionId)
        {
            if (Session["CustomerId"] == null)
            {
                TempData["IfLogin"] = "******";
                return(RedirectToAction("GoodsDetail", "FrontGoods", new { goodsId }));
            }
            var goods   = goodsService.GetGoodsByGoodsId(goodsId);
            var version = goodsService.GetVersionByVersionId(VersionId);

            ViewModelOrder orderDTO = new ViewModelOrder
            {
                CustomerId       = (int)Session["CustomerId"],
                GoodsId          = goods.GoodsId,
                GoodsName        = goods.GoodsName,
                OrderGoodsNumber = orderGoodsNumber,
                Price            = version.Price,
                VersionName      = version.VersionName,
                VersionId        = VersionId,
            };

            return(View(orderDTO));
        }
Exemplo n.º 9
0
        // GET: FrontOrder
        public ActionResult PlaceOrderByShoppingCar(string shoppingCarIdJsonStr, string goodsNumberJsonStr)
        {
            var shoppingCarIdList = shoppingCarIdJsonStr.Split(',');
            var goodsNumberList   = goodsNumberJsonStr.Split(',');
            var orders            = new List <ViewModelOrder>();

            for (int i = 0; i < shoppingCarIdList.Length; i++)
            {
                var anOrder     = new ViewModelOrder();
                var shoppingCar = userService.GetShoopingCarByShoppingCarId(int.Parse(shoppingCarIdList[i]));
                var goods       = goodsService.GetGoodsByGoodsId(shoppingCar.GoodsId);
                var version     = goodsService.GetVersionByVersionId(shoppingCar.VersionId);
                anOrder.VersionId   = shoppingCar.VersionId;
                anOrder.GoodsId     = shoppingCar.GoodsId;
                anOrder.GoodsName   = goods.GoodsName;
                anOrder.VersionName = version.VersionName;
                anOrder.Price       = version.Price;
                anOrder.CustomerId  = (int)Session["CustomerId"];

                anOrder.OrderGoodsNumber = int.Parse(goodsNumberList[i]);
                orders.Add(anOrder);
            }
            return(View(orders));
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Post(ViewModelOrder order)
        {
            _logger.LogInformation("Post Order", order);

            if (ModelState.IsValid && order.Botfield == null)
            {
                var findClient = await _clientRepo.ClientFindByEmail(order.Email);

                if (findClient == null)
                {
                    findClient = await _clientRepo.CreateClient(new Clients()
                    {
                        Email     = order.Email,
                        Phone     = order.Phone,
                        LastName  = order.ClientLastName,
                        FirstName = order.ClientFirstName
                    });

                    var createKadett = await _kadettRepo.CreateKadett(new Kadett()
                    {
                        LastName      = order.KadettLastName,
                        FirstName     = order.KadettFirstName,
                        KadettInKader = order.KadettInKader
                    });

                    var createOrder = await _orderRepo.CreateOrder(new Orders()
                    {
                        Bemerkung = order.Bemerkung,
                        OrderDate = DateTime.Now,
                        Client    = findClient,
                        Kadett    = createKadett
                    });

                    foreach (var ticket in order.Tickets)
                    {
                        Ticket ticketMatch = await _ticketRepo.GetByType(ticket.Type);

                        if (ticketMatch == null)
                        {
                            return(BadRequest());
                        }

                        var ticketOrder = await _ticketOrderRepo.CreateTicketOrder(new TicketOrder()
                        {
                            Order    = createOrder,
                            Ticket   = ticketMatch,
                            Quantity = ticket.Quantity,
                            Day      = ticket.Day
                        });
                    }
                    var email = await _clientRepo.ClientFindByEmail(order.Email);

                    if (email == null)
                    {
                        await _context.SaveChangesAsync();

                        if (!HostingEnvironment.IsDevelopment())
                        {
                            await _emailSenderService.SendEmailAsync(order.Email);
                        }
                        return(Ok());
                    }
                }
                return(Conflict());
            }
            return(ValidationProblem());
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Index(ViewModelOrder viewModel)
        {
            var mapper = new MapperConfiguration(conf => conf.CreateMap <ViewModelOrder, OrderDTO>()).CreateMapper();

            return(Redirect(await orderService.CreatOrder(mapper.Map <OrderDTO>(viewModel))));
        }