public Order Buy(Ordermodel model) { if (model != null) { var oder = new Order() { Fullname = model.Fullname, ProductName = model.ProductName, ProductPrice = model.ProductPrice, Adress = model.Adress, TinhThanhId = model.TinhThanhId, QuanHuyenId = model.QuanHuyenId, PhuongXaId = model.PhuongXaId, SoDienThoai = model.SoDienThoai, Soluong = model.Soluong, PurchaseForm = "Thanh toán đủ", Note = "Miễn phí giao hàng. Thanh toán đầy đủ khi nhận hàng", StateId = 1, ThoiDiemDatHang = DateTime.Now, Total = model.Soluong * model.ProductPrice, }; context.Order.Add(oder); context.SaveChanges(); return(oder); } return(null); }
public Order InstallmentPurchase(Ordermodel model) { if (model != null) { var info = System.Globalization.CultureInfo.GetCultureInfo("vi-VN"); var oder = new Order() { Fullname = model.Fullname, ProductName = model.ProductName, ProductPrice = model.ProductPrice, Adress = model.Adress, ThoiDiemDatHang = DateTime.Now, TinhThanhId = model.TinhThanhId, QuanHuyenId = model.QuanHuyenId, PhuongXaId = model.PhuongXaId, SoDienThoai = model.SoDienThoai, Soluong = model.Soluong, PurchaseForm = "Thanh toán trả góp", Note = $"Miễn phí giao hàng. Thanh toán trước 30%({String.Format(info, "{0:#,##0 đ}", Math.Round((model.ProductPrice * model.Soluong * 0.3) / 1000, 0) * 1000)}) khi nhận " + $"hàng. Mỗi tháng trả góp {String.Format(info, "{0:#,##0 đ}", Math.Round((model.ProductPrice * model.Soluong * 0.7 * 1.01 / 6) / 1000, 0) * 1000)} vào " + $"ngày {DateTime.Now.ToString("dd")} hàng tháng trong vòng 6 tháng tính từ thời điểm mua hàng", StateId = 1, Total = model.Soluong * model.ProductPrice, }; context.Order.Add(oder); context.SaveChanges(); return(oder); } return(null); }
public IActionResult Buy(Ordermodel model) { if (ModelState.IsValid) { var order = orderRepository.Buy(model); if (order != null) { return(RedirectToAction("OrderDetail", new { id = order.OrderId })); } } return(RedirectToAction("Detail", "Home")); }