public async Task Add(Article article)
        {
            var dbContext = new LMDbContext();
            await dbContext.Articles.AddAsync(article);

            await dbContext.SaveChangesAsync();
        }
        public async Task Add(List <Article> articles)
        {
            var dbContext = new LMDbContext();
            await dbContext.Articles.AddRangeAsync(articles);

            await dbContext.SaveChangesAsync();
        }
Exemple #3
0
    public async Task Add(Category category)
    {
        var dbContext = new LMDbContext();
        await dbContext.Categories.AddAsync(category);

        await dbContext.SaveChangesAsync();
    }
        public async Task Add(ShopCategory shopCategory)
        {
            var dbContext = new LMDbContext();
            await dbContext.ShopCategories.AddAsync(shopCategory);

            await dbContext.SaveChangesAsync();
        }
        public async Task Add(KnowledgeCategory knowledgeCategory)
        {
            var dbContext = new LMDbContext();
            await dbContext.KnowledgeCategories.AddAsync(knowledgeCategory);

            await dbContext.SaveChangesAsync();
        }
Exemple #6
0
        public async Task Add(ShopItem shopItem)
        {
            var dbContext = new LMDbContext();
            await dbContext.ShopItems.AddAsync(shopItem);

            await dbContext.SaveChangesAsync();
        }
        public async Task Delete(string username)
        {
            var context = new LMDbContext();
            var dbUser  = await FindByUsernameAsync(username);

            context.Users.Remove(dbUser);
        }
        public async Task Add(List <KnowledgeCategory> knowledgeCategories)
        {
            var dbContext = new LMDbContext();
            await dbContext.KnowledgeCategories.AddRangeAsync(knowledgeCategories);

            await dbContext.SaveChangesAsync();
        }
Exemple #9
0
        public async Task Add(List <ShopItem> shopItems)
        {
            var dbContext = new LMDbContext();
            await dbContext.ShopItems.AddRangeAsync(shopItems);

            await dbContext.SaveChangesAsync();
        }
        public async Task AddProduct(Product product)
        {
            var dbContext = new LMDbContext();
            await dbContext.Products.AddAsync(product);

            await dbContext.SaveChangesAsync();
        }
        public async Task Add(List <ShopCategory> shopCategories)
        {
            var dbContext = new LMDbContext();
            await dbContext.ShopCategories.AddRangeAsync(shopCategories);

            await dbContext.SaveChangesAsync();
        }
Exemple #12
0
    public async Task Update(Category category)
    {
        var dbContext        = new LMDbContext();
        var categoryToUpdate = await dbContext.Categories.FirstOrDefaultAsync(c => c.Id == category.Id);

        categoryToUpdate = category;
        await dbContext.SaveChangesAsync();
    }
        public async Task ConfirmEmailAsync(string email)
        {
            var context = new LMDbContext();
            var user    = await context.Users.FirstOrDefaultAsync(u => u.Username.ToUpper() == email.ToUpper());

            user.IsConfirmed = true;
            await context.SaveChangesAsync();
        }
Exemple #14
0
        public async Task Update(ShopItem shopItem)
        {
            var dbContext        = new LMDbContext();
            var shopItemToUpdate = await dbContext.ShopItems.FirstOrDefaultAsync(c => c.Id == shopItem.Id);

            shopItemToUpdate = shopItem;
            await dbContext.SaveChangesAsync();
        }
        public async Task UpdateProduct(Product product)
        {
            var dbContext       = new LMDbContext();
            var productToUpdate = await dbContext.Products.FirstOrDefaultAsync(p => p.Id == product.Id);

            productToUpdate = product;
            await dbContext.SaveChangesAsync();
        }
        public async Task Update(Article article)
        {
            var dbContext       = new LMDbContext();
            var articleToUpdate = await dbContext.Articles.FirstOrDefaultAsync(c => c.Id == article.Id);

            articleToUpdate = article;
            await dbContext.SaveChangesAsync();
        }
        public async Task Delete(int articleId)
        {
            var dbContext = new LMDbContext();
            var article   = await dbContext.Articles.FirstOrDefaultAsync(c => c.Id == articleId);

            dbContext.Remove(article);
            await dbContext.SaveChangesAsync();
        }
        public async Task DeleteProduct(string productId)
        {
            var dbContext = new LMDbContext();
            var product   = await dbContext.Products.FirstOrDefaultAsync(p => p.Id == productId);

            dbContext.Products.Remove(product);
            await dbContext.SaveChangesAsync();
        }
        public async Task Delete(int shopItemFeedbackId)
        {
            var dbContext        = new LMDbContext();
            var shopItemFeedback = await dbContext.ShopItemFeedbacks.FirstOrDefaultAsync(c => c.Id == shopItemFeedbackId);

            dbContext.Remove(shopItemFeedback);
            await dbContext.SaveChangesAsync();
        }
Exemple #20
0
    public async Task Delete(string categoryId)
    {
        var dbContext = new LMDbContext();
        var category  = await dbContext.Categories.FirstOrDefaultAsync(c => c.Id == categoryId);

        dbContext.Remove(category);
        await dbContext.SaveChangesAsync();
    }
        public async Task Update(ShopCategory shopCategory)
        {
            var dbContext            = new LMDbContext();
            var shopCategoryToUpdate = await dbContext.ShopCategories.FirstOrDefaultAsync(c => c.Id == shopCategory.Id);

            shopCategoryToUpdate = shopCategory;
            await dbContext.SaveChangesAsync();
        }
        public async Task Update(KnowledgeCategory knowledgeCategory)
        {
            var dbContext = new LMDbContext();
            var knowledgeCategoryToUpdate = await dbContext.KnowledgeCategories.FirstOrDefaultAsync(c => c.Id == knowledgeCategory.Id);

            knowledgeCategoryToUpdate = knowledgeCategory;
            await dbContext.SaveChangesAsync();
        }
        public async Task Delete(int shopCategoryId)
        {
            var dbContext    = new LMDbContext();
            var shopCategory = await dbContext.ShopCategories.FirstOrDefaultAsync(c => c.Id == shopCategoryId);

            dbContext.Remove(shopCategory);
            await dbContext.SaveChangesAsync();
        }
        public async Task Delete(string knowledgeCategoryId)
        {
            var dbContext         = new LMDbContext();
            var knowledgeCategory = await dbContext.KnowledgeCategories.FirstOrDefaultAsync(c => c.Id == int.Parse(knowledgeCategoryId));

            dbContext.Remove(knowledgeCategory);
            await dbContext.SaveChangesAsync();
        }
        public async Task Add(User user)
        {
            var context = new LMDbContext();

            user.Password = _hasher.HashPassword(user.Password);
            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();
        }
        public async Task UpdateRefreshToken(User user)
        {
            var context = new LMDbContext();
            var dbUser  = await FindByUsernameAsync(user.Username);

            context.Update(dbUser);
            dbUser.RefreshTokensStr = JsonConvert.SerializeObject(user.RefreshTokens);
            context.Update(dbUser);
            await context.SaveChangesAsync();
        }
        public async Task <bool> TryChangePasswordAsync(string newPassword)
        {
            var context = new LMDbContext();
            var dbUser  = await context.Users
                          .FirstOrDefaultAsync(u => u.Username.ToUpper() == GlobalHelpers.CurrentUser.Username.ToUpper());

            dbUser.Password = _hasher.HashPassword(newPassword);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <DailyNutrition> Add(DailyNutrition dailyNutrition)
        {
            dailyNutrition.Id     = null;
            dailyNutrition.UserId = GlobalHelpers.CurrentUser.Id;
            var dbContext = new LMDbContext();
            await dbContext.DailyNutritions.AddAsync(dailyNutrition);

            await dbContext.SaveChangesAsync();

            return(dailyNutrition);
        }
        public async Task Delete(string nutritionId)
        {
            if (GlobalHelpers.CurrentUser.DailyNutritions.Any(dn => dn.Id == nutritionId))
            {
                var context        = new LMDbContext();
                var dailyNutrition = await context.DailyNutritions.FirstOrDefaultAsync(dn => dn.Id == nutritionId);

                context.DailyNutritions.Remove(dailyNutrition);
                await context.SaveChangesAsync();
            }
        }
        public async Task Add(List <ShopItemFeedback> shopItemFeedbacks)
        {
            foreach (var item in shopItemFeedbacks)
            {
                item.Date = DateTime.Now;
            }

            var dbContext = new LMDbContext();
            await dbContext.ShopItemFeedbacks.AddRangeAsync(shopItemFeedbacks);

            await dbContext.SaveChangesAsync();
        }