public ToDoList CreateToDoList(ToDoListDTO list, string owner) { ToDoList result = list.ToEntity(); result.Position = _context.ToDoLists.Where(l => l.Owner == owner).Count(); result.Reminded = true; result.Owner = owner; _context.ToDoLists.Add(result); _context.SaveChanges(); return(result); }
public void UpdateToDoList(ToDoListDTO list, string owner) { ToDoList oldList = GetToDoList(list.Id, owner); if (oldList == null) { throw new EntityNotFoundException(); } else if (oldList.Owner != owner) { throw new UnauthorizedException(); } oldList.Update(list.ToEntity()); _context.SaveChanges(); }