public async Task <Response <TodoSet> > SaveAsync(TodoSet todoSet) { var user = await userManager.FindByNameAsync(userAccessor.GetLoggedUserEmail()); if (user == null) { return(Response <TodoSet> .Failure(ResponseResult.UserIsNotAuthorized, "Zaloguj się do systemu w celu wykonania operacji")); } var entity = new TodoSet { Id = Guid.NewGuid(), Name = todoSet.Name, Owner = user, Todos = new Collection <Todo>(), TodoSetTags = new Collection <TodoSetTags>() }; await todoSetRepository.SaveAsync(entity); await unitOfWork.CommitTransactionAsync(); return(Response <TodoSet> .Success(ResponseResult.Created)); }
public async Task <Response <TodoSet> > UpdateAsync(TodoSet todoSet, Guid id) { var currentTodoSet = await todoSetRepository.SearchAsync(id); if (currentTodoSet == null) { return(Response <TodoSet> .Failure(ResponseResult.ResourceDoesntExist, $"Zbiór zadań o id:{id} nie został znaleziony")); } currentTodoSet.Name = todoSet.Name; todoSetRepository.Update(currentTodoSet); await unitOfWork.CommitTransactionAsync(); return(Response <TodoSet> .Success(ResponseResult.Updated)); }
public TodoSet GetTodoSet(string username, string setname) { string filepath = Path.Combine(Environment.WebRootPath, $"todosets/{username}/{setname}"); return(TodoSet.BuildFromJson(System.IO.File.ReadAllText(filepath))); }
public void AddOrUpdateSet(string username, TodoSet set) { throw new NotImplementedException(); }
public void Update(TodoSet todoSet) { context.TodoSets.Update(todoSet); }
public async Task SaveAsync(TodoSet todoSet) { await context.TodoSets.AddAsync(todoSet); }
public void Delete(TodoSet todoSet) { context.TodoSets.Remove(todoSet); }