public async Task <IHttpActionResult> PostAssignment(Assignment assignment, string consultantId, int consultantTaskId, int assignerId) { logger.Info(DateTime.Now + ":" + "Inside the PostAssignment IHttpActionResult in the Assignments Controller"); if (!ModelState.IsValid) { logger.Info(DateTime.Now + ":" + "Inside the ModelState.IsValid in the Assignments Controller"); return(BadRequest(ModelState)); } try { logger.Info(DateTime.Now + ":" + "Inside the try block of the PostAssignment IHttpActionResult in the Assignments Controller"); await _assignment.AssignTaskToConsultant(assignment, consultantId, consultantTaskId, assignerId); } catch (DbEntityValidationException ex) { logger.Info(DateTime.Now + ":" + "The Error is :" + ex.Message); string message = ex.Message; throw new Exception(message); } return(CreatedAtRoute("DefaultApi", new { id = assignment.Id }, assignment)); }