public ResponseModel PostData(GetDataForMessaging request) { MessagingServices messagingServices = new MessagingServices(configuration); ResponseModel obj = messagingServices.SendMessage(request); ResponseModel response = new ResponseModel(); if (ModelState.IsValid) { if (obj.Data != null) { response.Data = obj.Data; response.StatusCode = Constants.StatusCode.Success; } else { response.Data = obj.Data; response.StatusCode = Constants.StatusCode.InternalServerError; response.Message = obj.Message; } } else { List <string> errorlist = new List <string>(); foreach (var modelState in ViewData.ModelState.Values) { foreach (var error in modelState.Errors) { errorlist.Add(error.ErrorMessage); } } response.Data = errorlist; response.StatusCode = StatusCodes.Status500InternalServerError; response.Message = Constants.Messages.SOMETHING_WENT_WRONG; return(response); } return(response); }