Пример #1
0
        public OrderDto AddOrder(OrderParameter orderParameter, int userId)
        {
            var additionalIds = orderParameter.AdditioalFoodIds?.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)) ?? new List <int>();

            var newOrder = new Order()
            {
                PrimaryFoodId    = orderParameter.PrimaryFoodId,
                AdditioalFoodIds = orderParameter.AdditioalFoodIds,
                OrderName        = this.GetFoodName(orderParameter.PrimaryFoodId, additionalIds),
                Reduced          = orderParameter.Reduced,
                Price            = this.GetTotalPrice(orderParameter.PrimaryFoodId, additionalIds) - orderParameter.Reduced,
                CreatedBy        = userId,
                CreatedAt        = DateTime.Now
            };

            _orderRepositories.AddOrder(newOrder);
            return(OrderDto.ToOrderDto(newOrder));
        }
Пример #2
0
        public OrderDto UpdateOrder(OrderParameter orderParameter, int userId)
        {
            var additionalIds = orderParameter.AdditioalFoodIds?.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)) ?? new List <int>();

            var order = _orderRepositories.GetOrder(orderParameter.Id);

            if (order != null)
            {
                order.PrimaryFoodId    = orderParameter.PrimaryFoodId;
                order.AdditioalFoodIds = orderParameter.AdditioalFoodIds;
                order.OrderName        = this.GetFoodName(orderParameter.PrimaryFoodId, additionalIds);
                order.Reduced          = orderParameter.Reduced;
                order.Price            = this.GetTotalPrice(orderParameter.PrimaryFoodId, additionalIds) - orderParameter.Reduced;
                order.UpdatedBy        = userId;
                order.UpdatedAt        = DateTime.Now;
                return(OrderDto.ToOrderDto(_orderRepositories.UpdateOrder(order)));
            }

            return(null);
        }
Пример #3
0
        public OrderDto GetOrder(int Id)
        {
            var order = _orderRepositories.GetOrder(Id);

            return(OrderDto.ToOrderDto(order));
        }