public ActionResult ViewMyOrderDetails(int OrderId) { try { if (Session["UserId"] != null) { OrderList_ViewModel OrderDetails = objDataBase.OrderMasters.Where(om => om.OrderId == OrderId) .Join(objDataBase.ProductMasters, om => om.ProductId, pm => pm.ProductId, (om, pm) => new { OrderMaster = om, ProductMaster = pm }) .Join(objDataBase.PictureMasters, ompm => ompm.OrderMaster.ProductId, picm => picm.ProductId, (ompm, picm) => new { OrderMaster = ompm.OrderMaster, ProductMaster = ompm.ProductMaster, PictureMaster = picm }) .Join(objDataBase.UserMasters, ompmpicm => ompmpicm.ProductMaster.UserId, um => um.UserId, (ompmpicm, um) => new { OrderMaster = ompmpicm.OrderMaster, ProductMaster = ompmpicm.ProductMaster, PictureMaster = ompmpicm.PictureMaster, UserMaster = um }) .Join(objDataBase.OrderStatusMasters, ompmpicmum => ompmpicmum.OrderMaster.OrderStatusId, os => os.OrderStatusId, (ompmpicmum, os) => new { OrderMaster = ompmpicmum.OrderMaster, ProductMaster = ompmpicmum.ProductMaster, PictureMaster = ompmpicmum.PictureMaster, UserMaster = ompmpicmum.UserMaster, OrderStatusMasters = os }) .Select(m => new OrderList_ViewModel { OrderId = m.OrderMaster.OrderId, ProductId = m.OrderMaster.ProductId, ProductName = m.ProductMaster.ProductName, Price = m.ProductMaster.Price, PictureId = m.PictureMaster.PictureId, PictureContent = m.PictureMaster.PictureContent, SellerId = m.ProductMaster.UserId, SellerName = m.UserMaster.FirstName + " " + m.UserMaster.LastName, OrderQuantity = m.OrderMaster.OrderQuantity, AvailableQuantity = m.ProductMaster.Quantity, PaymentAmount = m.OrderMaster.PaymentAmount, DeliveryAddress = m.OrderMaster.DeliveryAddress, ContactNum = m.OrderMaster.ContactNum, OrderAddedDate = m.OrderMaster.OrderAddedDate, OrderStatusId = m.OrderMaster.OrderStatusId, OrderStatusName = m.OrderStatusMasters.OrderStatusName }).FirstOrDefault(); //return PartialView("_ViewMyOrderDetails", OrderDetails); return(PartialView("../CustomerOrder/_ViewCustomerOrderDetails", OrderDetails)); } else { return(RedirectToAction("Login", "Login")); } } catch (Exception ex) { throw ex; } }
public ActionResult ViewCustomerOrderDetails(int OrderId) { try { // OrderList_ViewModel OrderDetails = new OrderList_ViewModel(); OrderList_ViewModel OrderDetails = (from om in objDbEntities.OrderMasters where om.OrderId == OrderId join pm in objDbEntities.ProductMasters on om.ProductId equals pm.ProductId join picm in objDbEntities.PictureMasters on om.ProductId equals picm.ProductId join um in objDbEntities.UserMasters on om.UserId equals um.UserId join os in objDbEntities.OrderStatusMasters on om.OrderStatusId equals os.OrderStatusId //where om.OrderId == OrderId -- Write where condition on top increase performance select new OrderList_ViewModel { OrderId = om.OrderId, ProductId = om.ProductId, ProductName = pm.ProductName, PictureId = picm.PictureId, PictureContent = picm.PictureContent, Price = pm.Price, BuyerId = om.UserId, BuyerName = um.FirstName + " " + um.LastName, OrderQuantity = om.OrderQuantity, AvailableQuantity = pm.Quantity, PaymentAmount = om.PaymentAmount, DeliveryAddress = om.DeliveryAddress, ContactNum = om.ContactNum, OrderAddedDate = om.OrderAddedDate, OrderStatusId = om.OrderStatusId, OrderStatusName = os.OrderStatusName, Active = om.Active, Deleted = om.Deleted }).FirstOrDefault(); return(PartialView("_ViewCustomerOrderDetails", OrderDetails)); } catch (Exception ex) { throw ex; } }