public HttpResponseMessage CreateUpdateReferral([FromBody] ReferralRequest payload) { try { ItemResponse <int> response = new ItemResponse <int>(); response.Item = _referralService.ReferralUpdateInsert(payload); if (payload.Accepted == true) { //add new message to the database that will notfiy user that their referral request was completed ConversationMsgAddRequest convo = new ConversationMsgAddRequest(); convo.SenderId = HttpContext.Current.User.Identity.GetUserId(); convo.ReceiverId = payload.CandidateGuid; convo.Subject = "Referral Request Accepted!"; var request = HttpContext.Current.Request; var address = string.Format("{0}://{1}", request.Url.Scheme, request.Url.Authority); convo.Content = "Check your 'My Referrals' page to see your updated referral requests here: " + address + "/Jobs/MyReferrals/"; _messagingService.CreateConversationMsg(convo); } return(Request.CreateResponse(response)); } catch (System.Exception ex) { //add to error log ErrorLogService svc = new ErrorLogService(); ErrorLogAddRequest error = new ErrorLogAddRequest(); error.ErrorFunction = "Sabio.Web.Controllers.Api.CreateReferral"; error.ErrorMessage = ModelState.ToString(); error.UserId = UserService.UserSelect().PersonId; svc.ErrorLogInsert(error); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }