Example #1
0
        public async Task Delete(Guid userId)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                var userModel = await dbContext.User.FirstOrDefaultAsync(n => n.UserId.Equals(userId));

                userModel.Active = false;
                await dbContext.SaveChangesAsync();
            }
        }
Example #2
0
        public async Task Delete(Guid todoId)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                var todo = await dbContext.ToDo.FirstOrDefaultAsync(n => n.ToDoId.Equals(todoId));

                todo.Active    = false;
                todo.UpDatedAt = DateTime.Now;
                await dbContext.SaveChangesAsync();
            }
        }
Example #3
0
 public async Task<User> Post(User user)
 {
     using (var dbContext = new Context.ToDoContext())
     {
         user.UserId = Guid.NewGuid();
         user.Active = true;
         user.CreatedAt = DateTime.Now;
         user.UpDatedAt = DateTime.Now;
         dbContext.User.Add(user);
         await dbContext.SaveChangesAsync();
         return await Task.Run(() => user);
     }
 }
Example #4
0
        public async Task <User> Post(User user)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                user.UserId    = Guid.NewGuid();
                user.Password  = user.Password;
                user.Active    = true;
                user.CreatedAt = DateTime.Now;
                user.UpDatedAt = DateTime.Now;
                dbContext.User.Add(user);
                await dbContext.SaveChangesAsync();

                return(await Task.Run(() => user));
            }
        }
Example #5
0
        public async Task <User> Put(Guid userId, User user)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                var userModel = await dbContext.User.FirstOrDefaultAsync(n => n.UserId.Equals(userId));

                userModel.Name      = user.Name;
                userModel.Email     = user.Email;
                userModel.UpDatedAt = DateTime.Now;
                await dbContext.SaveChangesAsync();

                user.UserId = userModel.UserId;
                return(await Task.Run(() => user));
            }
        }
Example #6
0
        public async Task <ToDo> Put(Guid todoId, ToDo todo)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                var todoModel = await dbContext.ToDo.FirstOrDefaultAsync(n => n.ToDoId.Equals(todoId));

                todoModel.Description = todo.Description;
                todoModel.Completed   = todo.Completed;
                todoModel.UpDatedAt   = DateTime.Now;
                await dbContext.SaveChangesAsync();

                todo.Completed = todoModel.Completed;
                todo.ToDoId    = todoModel.ToDoId;
                todo.UserId    = todoModel.UserId;
                return(await Task.Run(() => todo));
            }
        }
Example #7
0
        public async Task <ToDo> Post(Guid userId, ToDo todo)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                dbContext.ToDo.Add(new Entities.ToDo
                {
                    ToDoId      = todo.ToDoId = Guid.NewGuid(),
                    Description = todo.Description,
                    Completed   = false,
                    Active      = true,
                    UserId      = todo.UserId = userId,
                    CreatedAt   = DateTime.Now,
                    UpDatedAt   = DateTime.Now
                });

                await dbContext.SaveChangesAsync();

                return(await Task.Run(() => todo));
            }
        }
Example #8
0
 public async Task Delete(Guid userId)
 {
     using (var dbContext = new Context.ToDoContext())
     {
         var userModel = await dbContext.User.FirstOrDefaultAsync(n => n.UserId.Equals(userId));
         userModel.Active = false;
         await dbContext.SaveChangesAsync();
     }
 }
Example #9
0
 public async Task<User> Put(Guid userId, User user)
 {
     using (var dbContext = new Context.ToDoContext())
     {
         var userModel = await dbContext.User.FirstOrDefaultAsync(n => n.UserId.Equals(userId));
         userModel.Name = user.Name;
         userModel.Email = user.Email;
         userModel.UpDatedAt = DateTime.Now;
         await dbContext.SaveChangesAsync();
         user.UserId = userModel.UserId;
         return await Task.Run(() => user);
     }
 }
Example #10
0
        public async Task<ToDo> Post(Guid userId, ToDo todo)
        {
            using (var dbContext = new Context.ToDoContext())
            {
                dbContext.ToDo.Add(new Entities.ToDo
                {
                    ToDoId = todo.ToDoId = Guid.NewGuid(),
                    Description = todo.Description,
                    Completed = false,
                    Active = true,
                    UserId = todo.UserId = userId,
                    CreatedAt = DateTime.Now,
                    UpDatedAt = DateTime.Now
                });

                await dbContext.SaveChangesAsync();
                return await Task.Run(() => todo);
            }
        }
Example #11
0
 public async Task Delete(Guid todoId)
 {
     using (var dbContext = new Context.ToDoContext())
     {
         var todo = await dbContext.ToDo.FirstOrDefaultAsync(n => n.ToDoId.Equals(todoId));
         todo.Active = false;
         todo.UpDatedAt = DateTime.Now;
         await dbContext.SaveChangesAsync();
     }
 }
Example #12
0
 public async Task<ToDo> Put(Guid todoId, ToDo todo)
 {
     using (var dbContext = new Context.ToDoContext())
     {
         var todoModel = await dbContext.ToDo.FirstOrDefaultAsync(n => n.ToDoId.Equals(todoId));
         todoModel.Description = todo.Description;
         todoModel.Completed = todo.Completed;
         todoModel.UpDatedAt = DateTime.Now;
         await dbContext.SaveChangesAsync();
         todo.Completed = todoModel.Completed;
         todo.ToDoId = todoModel.ToDoId;
         todo.UserId = todoModel.UserId;
         return await Task.Run(() => todo);
     }
 }