Ejemplo n.º 1
0
        public ActionResult EditNote(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 editNoteResult = sageApiProxy.EditNote(note);
            var getNotesResult = sageApiProxy.GetNotes(note.TRANSNBR);

            if (editNoteResult.IsSucceed && getNotesResult.IsSucceed && getNotesResult.Entities != null)
            {
                workOrder.WorkNotes = getNotesResult.Entities;
                repository.Update(workOrder);
                _hub.UpdateSageWorkOrder(workOrder);
            }
            else
            {
                _log.ErrorFormat("Was not able to save note to sage. !result.IsSucceed");
                return(Error("Note save failed", $"EditNote method IsSucceed==false. {editNoteResult?.ErrorMassage}"
                             ));
            }
            return(Json(editNoteResult, JsonRequestBehavior.AllowGet));
        }