public void UpdateTask(UserDTO user, ScheduledTaskDTO task) { var entity = GetTask(user, task.Id); // update task and tags entity.Text = task.Text; UpdateTags(task.Id, task.Tags); Context.SaveChanges(); }
public void CreateTask(UserDTO user, ScheduledTaskDTO task) { // create task var entity = new ScheduledTask() { CreatedDate = DateTime.UtcNow, UserId = user.Id, DueDate = task.DueDate, Text = task.Text }; Context.ScheduledTasks.Add(entity); // update tags UpdateTags(task.Id, task.Tags); Context.SaveChanges(); }
public void UpdateTask([FromBody] ScheduledTaskDTO task) { var user = userService.GetOrCreateUser((ClaimsIdentity)User.Identity); scheduledTaskService.UpdateTask(user, task); }
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Success</returns> /// <exception cref="SwaggerException">A server side error occurred.</exception> public async System.Threading.Tasks.Task ApiTasksPostAsync(ScheduledTaskDTO task = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl).Append("/api/tasks"); var client_ = new System.Net.Http.HttpClient(); try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(task, _settings.Value)); content_.Headers.ContentType.MediaType = "application/json"; request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); foreach (var item_ in response_.Content.Headers) { headers_[item_.Key] = item_.Value; } ProcessResponse(client_, response_); var status_ = ((int)response_.StatusCode).ToString(); if (status_ == "200") { return; } else if (status_ != "200" && status_ != "204") { var responseData_ = await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", status_, responseData_, headers_, null); } } finally { if (response_ != null) { response_.Dispose(); } } } } finally { if (client_ != null) { client_.Dispose(); } } }
/// <returns>Success</returns> /// <exception cref="SwaggerException">A server side error occurred.</exception> public void ApiTasksPost(ScheduledTaskDTO task = null) { System.Threading.Tasks.Task.Run(async() => await ApiTasksPostAsync(task, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); }