public IActionResult sender() { List <Vm_Order> or = new List <Vm_Order> (); var qorder = db.Tbl_Order.Where(a => a.State == "send").OrderByDescending(a => a.Id).ToList(); if (qorder != null) { foreach (var item in qorder) { var qf = db.Tbl_Factors.Where(a => a.Id_Order == item.Id).ToList(); var user = db.Tbl_User.Where(a => a.Id == item.Id_user).SingleOrDefault(); int sum = 0; if (qf.Count() != 0) { foreach (var item1 in qf) { sum = sum + item1.Total_sum; } } Vm_Order q = new Vm_Order() { Id = item.Id, datesave = item.Date_Order.ToPersianDateString(), Total = sum, Pay = item.Pay, UserName = user.UserNameUs, phone = user.PhoneUs }; or.Add(q); } ViewBag.listp = or.OrderByDescending(a => a.Id).ToList(); } return(View()); }
public IActionResult list() { //TODO: Implement Realistic Implementation List <Vm_Order> or = new List <Vm_Order> (); var qorder = db.Tbl_Order.Where(a => a.Id_user == Convert.ToInt32(User.Identity.GetId()) && a.State == "save").OrderByDescending(a => a.Id).ToList(); if (qorder != null) { foreach (var item in qorder) { var qf = db.Tbl_Factors.Where(a => a.Id_Order == item.Id).ToList(); int sum = 0; if (qf.Count() != 0) { foreach (var item1 in qf) { sum = sum + item1.Total_sum; } } Vm_Order q = new Vm_Order() { Id = item.Id, datesave = item.Date_Order.ToPersianDateString(), Total = sum, Pay = item.Pay, }; or.Add(q); } ViewBag.listp = or.OrderByDescending(a => a.Id).ToList(); } return(View()); }