public FileResult DownloadFileBia(int id)
        {
            string filePath;
            var    orderDetail = OrderDetails.FirstOrDefault(p => p.OrderDetailId == id);

            if (orderDetail == null)
            {
                filePath = _orderDetailRepository.GetById(id).FilePathBia;
            }
            else
            {
                filePath = orderDetail.FilePathBia;
            }
            byte[] fileBytes = System.IO.File.ReadAllBytes(Server.MapPath(filePath));
            string fileName  = Path.GetFileName(filePath);

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
        public bool UpdateOrderDetail(OrderDetailEditModels model, out string message)
        {
            var OrderDetailEntity = _OrderDetailRepository.GetById(model.OrderId);

            if (OrderDetailEntity != null)
            {
                var gr = _OrderDetailRepository.getOrderDetail(model.OrderId, model.ProductId);
                if (gr != null)
                {
                    message = Constants.OrderDetailIsExist;
                    return(false);
                }
                OrderDetailEntity = model.MapToEditEntity(OrderDetailEntity);
                _OrderDetailRepository.Update(OrderDetailEntity);
                UnitOfwork.SaveChanges();
                message = Constants.UpdateSuccess;
                return(true);
            }
            message = Constants.UpdateFail;
            return(false);
        }
        public IActionResult EditDetails(int orderDetailId)
        {
            var orderDetail   = _orderDetailRepository.GetById(orderDetailId);
            var drink         = _drinkRepository.GetDrinkById(orderDetail.DrinkId);
            var toppings      = _toppingRepository.GetToppingByDrinkId(drink.Id);
            var otherToppings = _toppingRepository.Toppings.Except(toppings.SelectMany(tg => tg.Toppings), new ToppingCompare()).ToList();

            toppings.Add(new Data.ViewModels.GroupedTopping {
                Name = "Khác", Toppings = otherToppings
            });
            ViewBag.Toppings           = toppings;
            ViewBag.OtherToppings      = _toppingRepository.Toppings.Except(toppings.SelectMany(tg => tg.Toppings));
            ViewBag.DrinkSizes         = drink.DrinkSizes;
            ViewBag.IceOptions         = drink.IceOptions;
            ViewBag.SugarOptions       = drink.SugarOptions;
            ViewBag.DisplayIceOption   = drink.DisplayIceOption;
            ViewBag.DisplaySugarOption = drink.DisplaySugarOption;
            ViewBag.RequireIceOption   = drink.RequireIceOption;
            ViewBag.RequireSugarOption = drink.RequireSugarOption;

            return(PartialView("_EditDetails", _mapper.Map <EditOrderDetailModel>(orderDetail)));
        }
Exemple #4
0
        public IActionResult DeleteHistory(int id)
        {
            try
            {
                var orderDetail = _orderDetailRepository.GetById(id);

                if (orderDetail == null)
                {
                    return(BadRequest($"The OrderDetailId ({id}) does not exists!"));
                }

                orderDetail.IsDeleted = true;
                _orderDetailRepository.Update(orderDetail);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public OrderDetail GetOrderDetail(Int64 id)
        {
            var orderDetail = orderDetailRepository.GetById(id);

            return(orderDetail);
        }
Exemple #6
0
 public OrderDetail GetOrderDetail(long id)
 {
     return(_repository.GetById(id));
 }
 public OrderDetail GetById(int id)
 {
     return(orderDetailRepository.GetById(id));
 }
 public IActionResult Edit(Guid id)
 {
     return(View(_repository.GetById(id)));
 }