public HttpResponseMessage Edit(OfficeHourUpdateRequest model) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } SucessResponse response = new SucessResponse(); string userId = UserService.GetCurrentUserId(); _officeHourServices.Update(model, userId); return Request.CreateResponse(response); }
public HttpResponseMessage Edit(OfficeHourUpdateRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } SucessResponse response = new SucessResponse(); string userId = UserService.GetCurrentUserId(); _officeHourServices.Update(model, userId); return(Request.CreateResponse(response)); }
public async Task <HttpResponseMessage> Edit(OfficeHourUpdateRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } SucessResponse response = new SucessResponse(); string userId = UserService.GetCurrentUserId(); _officeHourServices.Update(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)); }
public void Update(OfficeHourUpdateRequest model, string userId) { var ohqId = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.OfficeHours_Update", inputParamMapper : delegate(SqlParameterCollection updateParameterCollection) { updateParameterCollection.AddWithValue("@Id", model.Id); updateParameterCollection.AddWithValue("@InstructorId", model.InstructorId); updateParameterCollection.AddWithValue("@Date", model.Date); updateParameterCollection.AddWithValue("@StartTime", model.StartTime); updateParameterCollection.AddWithValue("@EndTime", model.EndTime); updateParameterCollection.AddWithValue("@TimeZone", model.TimeZone); updateParameterCollection.AddWithValue("@Topic", model.Topic); updateParameterCollection.AddWithValue("@Instructions", model.Instructions); updateParameterCollection.AddWithValue("@SectionId", model.SectionId); updateParameterCollection.AddWithValue("@UserId", userId); }); if (model.Questions != null) { foreach (var Question in model.Questions) { if (Question.Question != null) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.OfficeHourQuestions_Update", inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@OfficeHourId", model.Id); parameterCollection.AddWithValue("@Question", Question.Question); parameterCollection.AddWithValue("@Response", Question.Response); parameterCollection.AddWithValue("@Grouping", Question.Grouping); parameterCollection.AddWithValue("@QuestionStatsId", Question.QuestionStatusId); //SqlParameter q = new SqlParameter("@Id", System.Data.SqlDbType.Int) // { // Direction = System.Data.ParameterDirection.Output // }; //parameterCollection.Add(q); }, returnParameters : delegate(SqlParameterCollection para) { int.TryParse(para["@Id"].Value.ToString(), out ohqId); }); } } foreach (var Question in model.Questions) { if (Question.Tag != null) { DataProvider.ExecuteNonQuery(GetConnection, "OfficeHourQuestionTags_DeleteByOfficeHourQuestionId", inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@OfficeHourQuestionId", ohqId); }); foreach (var TagId in Question.Tag) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.OfficeHourQuestionTags_Insert", inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@OfficeHourQuestionId", ohqId); parameterCollection.AddWithValue("@TagId", TagId); }); } } } } }
public void Update(OfficeHourUpdateRequest model, string userId) { var ohqId = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.OfficeHours_Update", inputParamMapper: delegate(SqlParameterCollection updateParameterCollection) { updateParameterCollection.AddWithValue("@Id", model.Id); updateParameterCollection.AddWithValue("@InstructorId", model.InstructorId); updateParameterCollection.AddWithValue("@Date", model.Date); updateParameterCollection.AddWithValue("@StartTime", model.StartTime); updateParameterCollection.AddWithValue("@EndTime", model.EndTime); updateParameterCollection.AddWithValue("@TimeZone", model.TimeZone); updateParameterCollection.AddWithValue("@Topic", model.Topic); updateParameterCollection.AddWithValue("@Instructions", model.Instructions); updateParameterCollection.AddWithValue("@SectionId", model.SectionId); updateParameterCollection.AddWithValue("@UserId", userId); }); if (model.Questions != null) { foreach (var Question in model.Questions) if (Question.Question != null) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.OfficeHourQuestions_Update", inputParamMapper: delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@OfficeHourId", model.Id); parameterCollection.AddWithValue("@Question", Question.Question); parameterCollection.AddWithValue("@Response", Question.Response); parameterCollection.AddWithValue("@Grouping", Question.Grouping); parameterCollection.AddWithValue("@QuestionStatsId", Question.QuestionStatusId); //SqlParameter q = new SqlParameter("@Id", System.Data.SqlDbType.Int) // { // Direction = System.Data.ParameterDirection.Output // }; //parameterCollection.Add(q); }, returnParameters: delegate(SqlParameterCollection para) { int.TryParse(para["@Id"].Value.ToString(), out ohqId); }); } foreach (var Question in model.Questions) if (Question.Tag != null) { DataProvider.ExecuteNonQuery(GetConnection, "OfficeHourQuestionTags_DeleteByOfficeHourQuestionId", inputParamMapper: delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@OfficeHourQuestionId", ohqId); }); foreach (var TagId in Question.Tag) { DataProvider.ExecuteNonQuery(GetConnection, "dbo.OfficeHourQuestionTags_Insert", inputParamMapper: delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@OfficeHourQuestionId", ohqId); parameterCollection.AddWithValue("@TagId", TagId); }); } } } }