public ActionResult AddNote(WorkOrderNoteModel model) { var workOrder = repository.SearchFor <SageWorkOrder>(x => x.WorkOrder == model.WorkOrderId).SingleOrDefault(); if (workOrder == null) { return(Error("Work Order does not exist", $"There are no Work Orders with ID: {model.WorkOrderId}. workOrder == null")); } var note = Mapper.Map <SageNote>(model); var addNoteResult = sageApiProxy.AddNote(note); var getNotesResult = sageApiProxy.GetNotes(note.TRANSNBR); if (addNoteResult.IsSucceed && getNotesResult.IsSucceed && getNotesResult.Entities != null) { workOrder.WorkNotes = getNotesResult.Entities; repository.Update(workOrder); _hub.UpdateSageWorkOrder(workOrder); } else { _log.ErrorFormat("Was not able to add note to sage. !result.IsSucceed"); return(Error("Note save failed", $"AddNote method IsSucceed==false. {addNoteResult?.ErrorMassage}" )); } return(Json(addNoteResult, JsonRequestBehavior.AllowGet)); }