public ActionResult paymentOrderIn(int id) { //check if user is login in App string username = User.Identity.Name; if (string.IsNullOrEmpty(username)) { return(RedirectToAction("login", "Account")); } // Declare productVM OrderInVM model; using (Db db = new Db()) { // Get the OrderIn OrderInDTO dto = db.OrderIn.Find(id); // Make sure OrderIn exists if (dto == null) { return(Content("هذا الفاتورة غير موجودة ")); } // init model model = new OrderInVM(dto); } // Return view with model return(View(model)); }
public ActionResult printOrderInfo(int id) { List <OrderInDetialsVM> listOrderInDetials; OrderInVM model; using (Db db = new Db()) { listOrderInDetials = db.OrderInDetials.Where(x => x.OrderId == id) .ToArray().Select(x => new OrderInDetialsVM(x)).ToList(); OrderInDTO dto = db.OrderIn.Find(id); model = new OrderInVM(dto); } ViewBag.OrderDate = model.OrderDate; ViewBag.Paidprice = model.PaidPrice; ViewBag.Unpaidprice = model.UnpaidPrice; ViewBag.payementDate = model.PayementDate.ToShortDateString(); return(View(listOrderInDetials)); }
public ActionResult paymentOrderIn(OrderInVM model) { // Get OrderIn id long id = model.Id; // Check model state if (!ModelState.IsValid) { ModelState.AddModelError("", "لم تتم عملية التعديل "); return(View(model)); } if (model.PaidPrice > model.UnpaidPrice) { ModelState.AddModelError("", "المبلغ الدخل أكثر من المبلغ المتبقي"); return(View(model)); } else { // Update OrdrIn using (Db db = new Db()) { OrderInDTO dto = db.OrderIn.Find(id); dto.PaidPrice += model.PaidPrice; dto.UnpaidPrice = dto.TotalePrice - dto.PaidPrice; if (model.TotalePrice == model.PaidPrice) { dto.PayementDate = DateTime.Now.Date; } db.SaveChanges(); } // Set TempData message TempData["SM"] = "تم عملية السداد بنجاح "; } // Redirect return(RedirectToAction("paymentOrderIn")); }