public ActionResult Pay(Invoice model, List <string> PaymentTypes) { model.PaymentDate = DateTime.Now; foreach (string item in PaymentTypes) { int PaymentId = Convert.ToInt32(item); model.PaymentTypeId = PaymentId; } model.OrderId = ((Order)Session["Order"]).OrderId; InvoiceRep ip = new InvoiceRep(); if (ip.Insert(model).IsSuccessed) { Order ord = (Order)Session["Order"]; if (Request.Cookies["id"] != null) { HttpCookie aCookie = Request.Cookies["id"]; int id = Convert.ToInt32(Server.HtmlEncode(aCookie.Value)); ord.MemberId = id; } OrderRep ordrep = new OrderRep(); ord.IsPay = true; ordrep.Update(ord); return(RedirectToAction("PaySucces", "Payment")); } else { return(View(model)); } }
public ActionResult Pay(Invoice model, List <string> PaymentTypes) { model.PaymentDate = DateTime.Now; foreach (string item in PaymentTypes) { int PaymentId = Convert.ToInt32(item); model.PaymentTypeId = PaymentId; } model.OrderId = ((Order)Session["Order"]).OrderId; InvoiceRep ip = new InvoiceRep(); if (ip.Insert(model).IsSuccessed) { List <Product> proList = new List <Product>(); Order ord = (Order)Session["Order"]; OrderRep ordrep = new OrderRep(); OrderDetailRep ordDetRep = new OrderDetailRep(); ProductRep proRep = new ProductRep(); Result <List <OrderDetail> > ordDetRes = ordDetRep.GetListByOrdId((int)model.OrderId); foreach (OrderDetail item in ordDetRes.ProcessResult) { Product pr = proRep.GetObjById(item.ProductId).ProcessResult; if (pr.Stock != null) { if (pr.Stock < item.Quantity) { string msg = "Yeterli sayida stok yok"; return(RedirectToAction("DetailList", "Order", new { msg = msg })); } else { pr.Stock -= item.Quantity; proList.Add(pr); } } } Member mem = (Member)Session["UserID"]; if (mem != null) { ord.MemberId = mem.UserId; ord.IsPay = true; ordrep.Update(ord); foreach (Product item in proList) { proRep.Update(item); } Session["Order"] = null; return(RedirectToAction("LatestOrders", "Home")); } else { return(RedirectToAction("SignIn", "Home")); } } else { return(View(model)); } }
public ActionResult Pay(string PaymentTypes, string addID) { Invoice model = new Invoice(); AddressRep ar = new AddressRep(); model.PaymentDate = DateTime.Now; int paymentTypeId = Convert.ToInt32(PaymentTypes); model.PaymentTypeID = paymentTypeId; model.OrderId = ((Order)Session["Order"]).OrderID; var addressId = Convert.ToInt32(addID); Address ad = ar.GetById(addressId).ProccessResult; model.Addresss = String.Format(ad.Name.ToUpper() + " " + ad.Phone + " " + ad.PostCode + " " + ad.TCNo); InvoiceRep irep = new InvoiceRep(); if (irep.Insert(model).IsSucceded) { Order ord = (Order)Session["Order"]; OrderREp oRep = new OrderREp(); ord.IsPay = true; oRep.Update(ord); //mail gönderme islemi Member m = (Member)Session["CurrentUser"]; EmailSend email = new EmailSend(); string subject = "Siparişiniz Bize Ulaşmıştır . . ."; string body = String.Format("<table style='border:1px solid black'>"); foreach (var item in ord.OrderDetails) { body += "<tr style='border:1px solid black'><td>" + item.Product.ProductName + "</td>" + "<td>" + item.Quantity + "</td>" + "<td>" + item.Price + "</td>"; } body += "<tr style='border:1px solid black'><td></td><td></td><td> Total Price :" + ord.TotalPrice + "₺ </td></table>"; email.mailSending(subject, body, m.Email); Session["Order"] = null; return(RedirectToAction("Index", "Home")); } else { return(View(model)); } }