示例#1
0
        /// <inheritdoc />
        public async Task CreateAsync(User user)
        {
            var userDao = _mappingService.Map <User, UserDao>(user);

            using (var context = new NoteTakingContext())
            {
                context.Users.Add(userDao);
                await context.SaveChangesAsync();
            }
        }
示例#2
0
        public async Task DeleteAsync(Guid id)
        {
            using (var context = new NoteTakingContext())
            {
                var storedUserDao = await context.Users.FirstOrDefaultAsync(u => u.Id == id);

                if (storedUserDao == null)
                {
                    return;
                }

                context.Entry(storedUserDao).State = EntityState.Deleted;
                await context.SaveChangesAsync();
            }
        }
示例#3
0
        public async Task UpdateAsync(User user)
        {
            using (var context = new NoteTakingContext())
            {
                var storedUserDao = await context.Users.FirstOrDefaultAsync(u => u.Id == user.Id);

                if (storedUserDao == null)
                {
                    return;
                }

                storedUserDao.UserName  = user.UserName;
                storedUserDao.FirstName = user.FirstName;
                storedUserDao.Lastname  = user.Lastname;
                await context.SaveChangesAsync();
            }
        }