public async Task <IActionResult> CreateRabbitSaleRecord(MRabbitsTreatmentRecords rabbit) { ViewBag.title = "Create Record"; try { rabbit.NameId = rabbit.NameId.ToUpper(); db.MRabbitsTreatmentRecords.Add(rabbit); TempData["type"] = "success"; TempData["msg"] = "Saved"; await db.SaveChangesAsync(); } catch (Exception ex) { TempData["type"] = "error"; TempData["msg"] = "Error: " + ex.Message; } return(RedirectToAction("AllRecords")); }
public async Task <IActionResult> EditRecord(MRabbitsTreatmentRecords rabbit) { ViewBag.title = "Edit Record"; try { db.Entry(rabbit).State = EntityState.Modified; await db.SaveChangesAsync(); TempData["msg"] = "Saved"; TempData["type"] = "success"; } catch (Exception ex) { TempData["msg"] = ex.Message; TempData["type"] = "error"; } return(RedirectToAction("EditRecord", "RabbitsTreatment", new { id = rabbit.Id })); }