public async Task <ActionResult> AddMsg([FromBody] Messages data) { if (!ModelState.IsValid) { return(BadRequest(new ChatMessage { Status = false, ModelStates = ModelState })); } try { var newmsg = await _msgservice.AddMsgAsync(data); if (newmsg == null) { return(BadRequest(new ChatMessage { Status = false })); } return(CreatedAtRoute("GetMessageRoute", new { id = newmsg.id }, newmsg)); } catch (Exception exp) { _Logger.LogError(exp.Message); return(BadRequest(new ChatMessage { Status = false })); } }