Ejemplo n.º 1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var status = _statusLogic.Get(id);

            if (status == null)
            {
                return(HttpNotFound());
            }
            return(View(status));
        }
Ejemplo n.º 2
0
        public void ProcessOrder(Cart cart, DeliveryDTO deliveryDto, UserDTO userDto)
        {
            foreach (var item in cart.Lines)
            {
                item.PriceSale = item.Good.PriceSale;
            }

            OrderDTO orderDto = new OrderDTO();

            orderDto.Status = _statusLogic.Get(1);

            orderDto.DateCreation = DateTime.Now;
            orderDto.DateSale     = DateTime.Now;
            orderDto.User         = userDto;
            orderDto.Sum          = cart.Lines.Sum(x => x.PriceSale * x.Number);
            orderDto.Delivery     = deliveryDto;

            Order order = new Order();

            order.Id           = orderDto.Id;
            order.User         = _clientRepository.Get(userDto.Id);
            order.DateCreation = DateTime.Now;
            order.DateSale     = DateTime.Now;
            order.Sum          = orderDto.Sum;

            var delivery = Mapper.Map <DeliveryDTO, Delivery>(deliveryDto);
            var status   = Mapper.Map <StatusDTO, Status>(_statusLogic.Get(1));

            order.Status   = status;
            order.Delivery = delivery;

            _repository.Add(order);

            var items = cart.Lines;

            foreach (OrderItemDTO itemDto in items)
            {
                itemDto.Good  = _goodLogic.Get(itemDto.Good.Id);
                itemDto.Order = new OrderDTO {
                    Id = order.Id
                };
                _orderItemLogic.Add(itemDto);
            }
        }
        public IHttpActionResult Get(long id)
        {
            Status item = Logic.Get(id);

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
Ejemplo n.º 4
0
        public ActionResult ChangeStatus(int?id, string status)
        {
            //TODO: refactor use modelview
            //TODO: узнать стоит ли перенести этот код в BLL (using MVC in BLL)
            var statuses = _statusLogic.GetAll().
                           Select(s => new SelectListItem
            {
                Text  = s.Name,
                Value = s.Id.ToString()
            }).ToList();

            ViewBag.Statuses = statuses;

            var order = _orderLogic.Get(id);

            if (status != null)
            {
                var statusId = int.Parse(status);

                order.Status = _statusLogic.Get(statusId);

                _orderLogic.Edit(order);
            }

            var orderDetails = new OrderDetailsModel
            {
                Id           = order.Id,
                DateCreation = order.DateCreation,
                DateSale     = order.DateSale.ToShortDateString(),
                Status       = order.Status.Name,
                Sum          = order.Sum
            };

            if (order.User != null)
            {
                orderDetails.User = order.User.Name;
            }

            orderDetails.Statuses = statuses;

            return(PartialView(orderDetails));
        }