public ActionResult Save(OrderForm product) { using (var db = new LifeIsFeudalDb()) { try { db.OrderForms.Add(product); db.SaveChanges(); product.OrderNumber = product.Id.ToString().PadLeft(5, '0'); db.Entry(product).State = EntityState.Modified; db.SaveChanges(); var ret = new { OrderNumber = product.OrderNumber, PlayerName = product.PlayerName }; return(Json(ret)); } catch (Exception ie) { var e = ie; return(Json(ie)); } } }
public ActionResult Save(ItemQuality item) { using (var db = new LifeIsFeudalDb()) { if (item.Id == 0) { db.ItemQualities.Add(item); } else { var existing = db.ItemQualities.ToList().FirstOrDefault(x => x.Id == item.Id); existing.BuyActive = item.BuyActive; existing.SellActive = item.SellActive; existing.Item_Id = item.Item_Id; existing.ItemQualityType_Id = item.ItemQualityType_Id; existing.Free = item.Free; existing.OverridePrice = item.OverridePrice; db.Entry(existing).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); var ret = new { buy_active = item.BuyActive, id = item.Id, Item_id = item.Item_Id, ItemQualityType_id = item.ItemQualityType_Id, sell_active = item.SellActive, created_at = item.Created, free = item.Free, overridePrice = item.OverridePrice }; return(Json(ret, JsonRequestBehavior.AllowGet)); } }
public ActionResult Save(Configuration config) { using (var db = new LifeIsFeudalDb()) { db.Entry(config).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(config)); } }
public ActionResult SaveItem(Item item) { using (var db = new LifeIsFeudalDb()) { if (item.Id == 0) { db.Items.Add(item); return(Json(item)); } else { var findExisting = db.Items.ToList().FirstOrDefault(x => x.Id == item.Id); findExisting.Name = item.Name; findExisting.Price = item.Price; findExisting.SubCategory_Id = item.SubCategory_Id; findExisting.Category_Id = item.Category_Id; db.Entry(findExisting).State = System.Data.Entity.EntityState.Modified; return(Json(item)); } } }