public List <Rate> updateRows([FromBody] List <Rate> rates) { var xp = 5; List <Rate> newRates = new List <Rate>(); using (var db = new Service5nContext()) { for (int i = 0; i < rates.Count; i++) { Rate rate = new Rate(); rate = db.Rates.Where(p => p.IdRate == rates[i].IdRate).FirstOrDefault(); if (!(rates[i].name == rate.name && rates[i].description == rate.description && rates[i].price == rate.price)) { db.Rates.Remove(rate); db.Rates.Add(rates[i]); } } newRates = db.Rates.ToList(); db.SaveChanges(); return(newRates); } }
public void UpdateTarrif([FromBody] List <Rate> rates) { using (var db = new Service5nContext()) { for (int i = 0; i < rates.Count; i++) { db.Rates.Add(rates[i]); } db.SaveChanges(); } }
public void PostRequest([FromBody] Rate ratenk) { Rate rate = new Rate(); rate.name = ratenk.name; rate.description = ratenk.description; rate.price = ratenk.price; using (var db = new Service5nContext()) { db.Rates.Add(rate); db.SaveChanges(); } }