public async Task <string> AddCommentAsync(CommentViewModel item)
        {
            using (var db = dbContextFactory.CreateDbContext(_appConfig))
            {
                var dbItem = _mapper.Map <Comment>(item);
                db.Comments.Add(dbItem);
                var id = await db.SaveChangesAsync();

                return(id.ToString());
            }
        }
예제 #2
0
        public async Task <string> AddWishItemAsync(WishListItemViewModel item)
        {
            var dbWishList = _mapper.Map <WishListItem>(item);

            using (var db = dbContextFactory.CreateDbContext(_appConfig))
            {
                db.WishListItems.Add(dbWishList);
                var id = await db.SaveChangesAsync();

                return(id.ToString());
            }
        }
        public async Task AddUserAsync(int receiverId)
        {
            using (var db = dbContextFactory.CreateDbContext(_appConfig))
            {
                var santa = new SecretSanta
                {
                    ReceiverUserId = receiverId,
                    SantaUserId    = null
                };

                db.SecretSantas.Add(santa);
                await db.SaveChangesAsync();
            }
        }
예제 #4
0
        public async Task AddUserAsync(UserViewModel item)
        {
            var dbUser = _mapper.Map <UserViewModel, User>(item);

            using (var db = dbContextFactory.CreateDbContext(_appConfig))
            {
                db.Users.Add(dbUser);
                await db.SaveChangesAsync();
            }
        }