public async Task <IActionResult> PutTodoTask(Guid Id, TodoTaskFinal todoTaskFinal) { if (Id != todoTaskFinal.Id) { return(BadRequest()); } TodoTask todoTask = _context.TodoTask.Find(todoTaskFinal.Id); if (todoTask != null) { todoTask.Task = todoTaskFinal.Task; todoTask.Date = todoTaskFinal.Date; todoTask.Description = todoTaskFinal.Description; todoTask.Place = todoTaskFinal.Place; _context.Entry(todoTask).State = EntityState.Modified; } try { string userId = User.Claims.First(c => c.Type == "UserId").Value; if (todoTaskFinal.UserId == userId) { await _context.SaveChangesAsync(); } } catch (DbUpdateConcurrencyException) { if (!TodoTaskExists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <EventList> > PostEventList(Guid taskId, List <string> userIds) { string userId = User.Claims.First(c => c.Type == "UserId").Value; var user = await _userManager.FindByIdAsync(userId); foreach (var item in userIds) { EventList eventList = new EventList(); eventList.TaskId = taskId; eventList.UserId = item; _context.EventLists.Add(eventList); await _context.SaveChangesAsync(); } //eventList.Task = eventListVM.Task; //eventList.Date = eventListVM.Date; //eventList.UserId = eventListVM.UserId; //eventList.UserName = user.UserName; //_context.EventLists.Add(eventList); // await _context.SaveChangesAsync();//mistake async return(CreatedAtAction("GetEventList", new { id = taskId, userIds })); }