public ActionResult Edit(int id) { if (id > 0) { var order = _orderRepository.GetMany(x => !x.IsDeleted && x.Id == id) .Include(x => x.OrderDetails.Select(c => c.Product.Category)) .FirstOrDefault(); if (order != null) { var toReturn = Mapper.Map <Order, OrderAdminModel>(order); var orderstatues = _orderStatusRepository.GetMany(x => !x.IsDeleted).Select(x => new { Id = x.Id, Name = x.Name }).ToList(); var paymentMethods = _paymentMethodRepository.GetMany(x => !x.IsDeleted).Select(x => new { Id = x.Id, Name = x.Name }).ToList(); ViewBag.Orderstatues = orderstatues; ViewBag.PaymentMethods = paymentMethods; return(View(toReturn)); } else { return(null); } } return(null); }