public string ValidateCaseNote(CaseNoteViewModel caseNoteViewModel)
 {
     if (caseNoteViewModel.Type == 0)
     {
         return("Type Not Provided");
     }
     if (string.IsNullOrEmpty(caseNoteViewModel.NoteText))
     {
         return("NoteText Provided");
     }
     return(string.Empty);
 }
Ejemplo n.º 2
0
        public IHttpActionResult SaveCaseNote(RequestCarrier requestCarrier)
        {
            ResponseCarrier response;

            if (requestCarrier != null && requestCarrier.TanentId != 0 && requestCarrier.From != string.Empty && requestCarrier.UserId.HasValue && requestCarrier.UserId.Value > 0)
            {
                CaseNoteViewModel cViewModel = WebCommon.Instance.GetObject <CaseNoteViewModel>(requestCarrier.PayLoad);
                cViewModel.TanentId = requestCarrier.TanentId;
                string validationResponse = this._consultationMapper.ValidateCaseNote(cViewModel);
                if (string.IsNullOrEmpty(validationResponse))
                {
                    var caseNoteModel = this._consultationMapper.MapCaseNote(cViewModel);
                    caseNoteModel.CreatedBy        = (int)requestCarrier.UserId.Value;
                    caseNoteModel.CreatedByEntity  = Convert.ToInt32(requestCarrier.From);
                    caseNoteModel.ModifiedBy       = (int)requestCarrier.UserId.Value;
                    caseNoteModel.ModifiedByEntity = Convert.ToInt32(requestCarrier.From);
                    var caseNoteResponse = _dataServices.ConsultationService.SaveCaseNote(caseNoteModel);
                    if (caseNoteResponse.Success)
                    {
                        cViewModel.Id = caseNoteResponse.Id;
                        response      = new ResponseCarrier()
                        {
                            Status = true, PayLoad = cViewModel, TanentId = requestCarrier.TanentId
                        };
                    }
                    else
                    {
                        response = new ResponseCarrier()
                        {
                            Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = caseNoteResponse.ErrorMessage
                        };
                    }
                }
                else
                {
                    response = new ResponseCarrier()
                    {
                        Status = false, TanentId = requestCarrier.TanentId, ErrorMessage = validationResponse
                    };
                }
            }
            else
            {
                response = new ResponseCarrier()
                {
                    Status = false, PayLoad = null, ErrorMessage = "TanentId or RequestFrom or UserId not provided.", TanentId = requestCarrier.TanentId
                };
            }
            return(Json(response));
        }
 public CaseNoteModel MapCaseNote(CaseNoteViewModel vmodel)
 {
     return(new CaseNoteModel
     {
         NoteText = vmodel.NoteText,
         ConsultationId = vmodel.ConsultationId,
         Type = vmodel.Type,
         ModifiedBy = vmodel.ModifiedBy,
         ModifiedByEntity = vmodel.ModifiedEntity,
         ModifiedOn = vmodel.ModifiedOn,
         CreatedBy = vmodel.CreatedBy,
         CreatedByEntity = vmodel.CreatedByEntity,
         CreatedOn = vmodel.CreatedOn,
         TenantID = vmodel.TanentId
     });
 }