예제 #1
0
        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));
        }
예제 #2
0
        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();
 }
예제 #5
0
 public void Update(TodoSet todoSet)
 {
     context.TodoSets.Update(todoSet);
 }
예제 #6
0
 public async Task SaveAsync(TodoSet todoSet)
 {
     await context.TodoSets.AddAsync(todoSet);
 }
예제 #7
0
 public void Delete(TodoSet todoSet)
 {
     context.TodoSets.Remove(todoSet);
 }