public ActionResult Checkout() { string username = (string)Session["username"]; int coin = (int)Session["coin"]; Cart cart = (Cart)Session["cart"]; if ((int)Session["coin"] < cart.Items.Sum(x => x.Quantity * x.product.Price)) { return(RedirectToAction("ViewCart", "Cart")); } else { foreach (Item it in cart.Items) { for (int i = it.Quantity; i > 0; i--) { Guid GI = Guid.NewGuid(); int userid = UserData.GetId(username); int productid = it.ProductId; DateTime od = DateTime.Today; ActCode newcode = new ActCode(userid, productid, GI, od); CodeData.AddCode(newcode); coin -= it.product.Price; cart.Items.Where(x => x.ProductId == it.ProductId).FirstOrDefault().Quantity -= 1; } UserData.UpdateCoin(username, coin); Session["coin"] = coin; } } return(RedirectToAction("MyPurchases", "Purchases")); }
public TP146227GB02_ServiceEvent(ActCode act) : base() { string actCode = ""; switch (act) { case ActCode.PROC: actCode = "PROC"; break; case ActCode.CLNTRL: actCode = "CLNTRL"; break; case ActCode.INFRM: actCode = "INFRM"; break; case ActCode.PCPR: actCode = "PCPR"; break; case ActCode.SPCOBS: actCode = "SPCOBS"; break; case ActCode.OBSSER: actCode = "OBSSER"; break; case ActCode.SBADM: actCode = "SBADM"; break; default: break; } ServiceEvent = new ActClass(actCode, "EVN"); ServiceEvent.SetTemplateId(OIDStore.OIDTemplatesTemplateId, TEMPLATEID + "#" + TEMPLATETEXT); }
public static void AddCode(ActCode code) { using (var db = new ESDbContext()) { db.ActCode.Add(code); db.SaveChanges(); } }
public TP146227GB02_ServiceEvent(ActCode act) : base() { string actCode = ""; switch (act) { case ActCode.PROC: actCode = "PROC"; break; case ActCode.CLNTRL: actCode = "CLNTRL"; break; case ActCode.INFRM: actCode = "INFRM"; break; case ActCode.PCPR: actCode = "PCPR"; break; case ActCode.SPCOBS: actCode = "SPCOBS"; break; case ActCode.OBSSER: actCode = "OBSSER"; break; case ActCode.SBADM: actCode = "SBADM"; break; default: break; } ServiceEvent = new ActClass(actCode, "EVN"); ServiceEvent.SetTemplateId(OIDStore.OIDTemplatesTemplateId, TEMPLATEID + "#" + TEMPLATETEXT); }