public bool AddOrUpdate(DOCUS_ASM_ASSIGNMENTS assignment) { if (ModelState.IsValid) { return(_assignment.Update(assignment)); } else { return(false); } }
public JsonResult AddOrUpdate(DOCUS_ASM_ASSIGNMENTS assignment) { JsonResult result = new JsonResult(); if (ModelState.IsValid) { var notesTobeSaved = new AssignmentNotes(); var notesResponse = true; if (!assignment.Notes.IsNullOrWhiteSpace()) { notesTobeSaved.ASSIGNMENT_ID = assignment.ASSIGNMENT_ID; notesTobeSaved.NOTE = assignment.Notes; } //return _assignment.Create(assignment); switch (assignment.TransactionType) { case "New Request": // assignment.DATE_ENTERED = DateTime.Now.To var response = _assignment.Create(assignment); if (!assignment.Notes.IsNullOrWhiteSpace()) { notesTobeSaved.ASSIGNMENT_ID = response; notesResponse = _notes.SaveNotes(notesTobeSaved); } result = Json( new { data = response > 0 && notesResponse ? "Record Created Successuflly" : "Error Occurred", IsSuccess = result }); //RedirectToAction("Index", "Home",new{ id = assignment.ACCOUNT_NUMBER}); break; default: var update = _assignment.Update(assignment); if (!assignment.Notes.IsNullOrWhiteSpace()) { notesResponse = _notes.SaveNotes(notesTobeSaved); } result = Json(new { data = update && notesResponse ? "Record Updated Successuflly" : "Error Occurred", IsSuccess = result }); //RedirectToAction("Index", "Home", new { id = assignment.ACCOUNT_NUMBER }); break; } } else { var errors = ModelState.Where(x => x.Value.Errors.Count > 0); result = Json(new { data = errors, IsSuccess = false }); } return(result); }
public JsonResult AddOrUpdate(DOCUS_ASM_ASSIGNMENTS assignment) { JsonResult result = new JsonResult(); if (ModelState.IsValid) { //return _assignment.Create(assignment); switch (assignment.TransactionType) { case "New Request": var response = _assignment.Create(assignment); result = Json(new { data = response ? "Record Created Successuflly" : "Error Occurred", IsSuccess = result }); break; default: var update = _assignment.Update(assignment); result = Json(new { data = update ? "Record Updated Successuflly" : "Error Occurred", IsSuccess = result }); break; } } return(result); }