public JsonResult UpdateBerryPrice(Prices prices) { KoskenkorvanLuomutilaEntities3 entity = new KoskenkorvanLuomutilaEntities3(); string berry = prices.Berry; bool success = false; Price oldPrice = (from p in entity.Prices where p.Berry == berry select p).FirstOrDefault(); if (oldPrice != null) { oldPrice.Berry = prices.Berry; oldPrice.Price_per_litre = prices.Price_Per_Litre; entity.SaveChanges(); success = true; } entity.Dispose(); return(Json(success)); }
public JsonResult AddNewItem(Prices prices) { KoskenkorvanLuomutilaEntities3 entity = new KoskenkorvanLuomutilaEntities3(); bool success = false; Price price = new Price(); price.Berry = prices.Berry; price.Price_per_litre = prices.Price_Per_Litre; entity.Prices.Add(price); entity.SaveChanges(); entity.Dispose(); return(Json(success)); }