public void UpdateNok(VNok nok) { using (_context) { var dbnok = _context.NextOfKins.Where(t => t.ID == nok.ID).FirstOrDefault(); if (dbnok != null) { dbnok.OtherNames = nok.Othernames; dbnok.Surname = nok.Surname; dbnok.CellphoneNumber = nok.Cellphone; dbnok.Email = nok.Email; _context.SaveChanges(); base.Audittrail(new VAuditTrails() { Action = "Update", ActionBy = 1, ActionDate = DateTime.Now, RecordTable = "NextOfKins", RecordID = nok.ID, Record = JsonConvert.SerializeObject(nok) }); } } }
public VNok Add(VNok nok) { using (_context) { var newnok = new NextOfKins() { CellphoneNumber = nok.Cellphone, Email = nok.Email, OtherNames = nok.Othernames, Surname = nok.Surname, PatientID = nok.Patientid, Active = true }; _context.NextOfKins.Add(newnok); _context.SaveChanges(); nok.ID = newnok.ID; base.Audittrail(new VAuditTrails() { Action = "Insert", ActionBy = 1, ActionDate = DateTime.Now, RecordTable = "NextOfKins", RecordID = nok.ID, Record = JsonConvert.SerializeObject(nok) }); return(nok); } }
public JsonResult Update(VNok record) { try { _nok.UpdateNok(record); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult Create(VNok Nok) { try { if (Nok.Patientid == 0) { return(Json(new { Result = "ERROR", Message = "Please Add Biodata First" })); } else { //Add var addednok = _nok.Add(Nok); return(Json(new { Result = "OK", Record = addednok })); } } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }