public IActionResult DeleteCentury(CenturyViewModel model) { bool status = false; var x = _db.Century.FirstOrDefault(a => a.Centuries.Equals(model.Centuries)); if (x != null) { _db.Century.Remove(x); _db.SaveChanges(); status = true; } return(Json(status)); }
public IActionResult UpdateCentury(CenturyViewModel model) { bool status = false; if (ModelState.IsValid) { var century = _db.Century.FirstOrDefault(x => x.Centuries.Equals(model.Centuries)); using (var memoryStream = new MemoryStream()) { model.Data.CopyTo(memoryStream); century.Data = memoryStream.ToArray(); } _db.SaveChanges(); status = true; } return(Json(status)); }
public IActionResult AddCentury(CenturyViewModel model) { bool status = false; if (ModelState.IsValid) { var century = new Century(); century.Centuries = model.Centuries; using (var memoryStream = new MemoryStream()) { model.Data.CopyTo(memoryStream); century.Data = memoryStream.ToArray(); } _db.Century.Add(century); _db.SaveChanges(); status = true; } return(Json(status)); }