public ActionResult OrderA(int id, short vnum, byte amount) { if (Session["auth"] == null || Session["user"] == null) { return(RedirectToAction("Login", "Connection")); } if (Session["id"] == null && Session["user"] != null && Session["auth"] != null) { return(RedirectToAction("Select", "Personnage")); } using (opennosEntities2 context = new opennosEntities2()) { IEnumerable <Character> result = context.Character; var productsQuery = result.Where(x => x.CharacterId == id); using (opennosEntities1 test = new opennosEntities1()) { IEnumerable <shopping> resultat = from Price in test.shopping select Price; var productQuery = resultat.Where(x => x.VNum == vnum); if (productQuery == null) { Response.Redirect("Product/Index"); } foreach (var prod in productsQuery) { foreach (var shop in productQuery) { if (shop.Price * Convert.ToByte(amount) > prod.SpPoint) { Response.Redirect("Order/Index"); } else { int sky = prod.SpPoint - (shop.Price * Convert.ToByte(amount)); prod.SpPoint = sky; if (MallServiceClient.Instance.Authenticate(ConfigurationManager.AppSettings["MasterAuthKey"])) { MallServiceClient.Instance.SendItem(id, new MallItem() { ItemVNum = vnum, Amount = Convert.ToByte(amount), Rare = 0, Upgrade = 0 }); } else { return(View("Index")); } } } } } context.SaveChanges(); } return(View("OrderA")); }
public ActionResult Login(Account b) { if (Session["auth"] != null && Session["user"] != null && Session["id"] != null) { return(RedirectToAction("Index", "Product")); } if (Session["id"] == null && Session["auth"] != null && Session["user"] != null) { return(RedirectToAction("Select", "Personnage")); } if (ModelState.IsValid) { using (opennosEntities2 dc = new opennosEntities2()) { if (b.Password == null) { return(RedirectToAction("Login", "Connection")); } string pass = Sha512(b.Password); var v = dc.Account.Where(a => a.Name.Equals(b.Name) && a.Password.Equals(pass)).FirstOrDefault(); if (v != null) { Session["auth"] = v.AccountId.ToString(); Session["user"] = v.Name.ToString(); return(RedirectToAction("Index", "Personnage")); } else { return(RedirectToAction("Login", "Connection")); } } } return(View(b)); }
public ActionResult Select(string name) { if (Session["auth"] == null) { return(RedirectToAction("Login", "Connection")); } if (Session["id"] != null && Session["auth"] != null) { return(RedirectToAction("Index", "Product")); } using (opennosEntities2 context = new opennosEntities2()) { IEnumerable <Character> result = context.Character; var product = result.Where(x => x.Name == name); foreach (var chara in product) { Session["id"] = chara.CharacterId; } } return(RedirectToAction("Index", "Product")); }