public HttpResponseMessage Add(OfficeHourAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); string userId = UserService.GetCurrentUserId(); response.Item = _officeHourServices.Add(model, userId); return(Request.CreateResponse(response)); }
//public HttpResponseMessage Add(OfficeHourAddRequest model) public async Task <HttpResponseMessage> Add(OfficeHourAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); string userId = UserService.GetCurrentUserId(); response.Item = _officeHourServices.Add(model, userId); await SendEmail(model); //ItemsResponse<UserSection> EmailList = new ItemsResponse<UserSection>(); //EmailList.Items = _officeHourServices.GetEmailList(model.SectionId); //foreach (var items in EmailList.Items) //{ // await _messagingService.SendAddOfficeHourEmail(items.Email, model); //} return(Request.CreateResponse(response)); }