Beispiel #1
0
 public async Task AddCategoryAsync(CategoryDetailsModel categoryDetails)
 {
     if (_dbConnection != null)
     {
         try
         {
             var allCategories = from category in _dbConnection.Table <CategoryDetailsModel>() where category.CategoryName == categoryDetails.CategoryName select category;
             if (allCategories != null && await allCategories.CountAsync() >= 1)
             {
                 await _dbConnection.UpdateAsync(categoryDetails);
             }
             else
             {
                 await _dbConnection.InsertAsync(categoryDetails);
             }
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.ToString());
         }
     }
     else
     {
         Debug.WriteLine("failed to get sqlite connection");
     }
 }
Beispiel #2
0
        public async Task UpdateCategoryPinValueAsync(string categoryName, bool isPinned)
        {
            if (_dbConnection != null)
            {
                try
                {
                    var allCategories = from category in _dbConnection.Table <CategoryDetailsModel>() where category.CategoryName == categoryName select category;
                    if (allCategories != null)
                    {
                        CategoryDetailsModel tempCategory = await allCategories.FirstOrDefaultAsync();

                        tempCategory.IsPinned = isPinned;
                        await _dbConnection.UpdateAsync(tempCategory);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }
            }
            else
            {
                Debug.WriteLine("failed to get db connection");
            }
        }
Beispiel #3
0
        public async Task UpdateCategoryLastAccessedValueAsync(string categoryName, DateTime lastFetchedDateTime)
        {
            if (_dbConnection != null)
            {
                try
                {
                    var allCategories = from category in _dbConnection.Table <CategoryDetailsModel>() where category.CategoryName == categoryName select category;
                    if (allCategories != null)
                    {
                        CategoryDetailsModel tempCategory = await allCategories.FirstOrDefaultAsync();

                        if (tempCategory != null)
                        {
                            tempCategory.LastFetchedTime = lastFetchedDateTime;
                            await _dbConnection.UpdateAsync(tempCategory);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }
            }
            else
            {
                Debug.WriteLine("failed to get db connection");
            }
        }
Beispiel #4
0
        public async Task <CategoryDetailsModel> GetCategoryDetailAsync(string categoryName)
        {
            CategoryDetailsModel categoryObj = null;

            if (_dbConnection != null)
            {
                try
                {
                    var allCategories = from category in _dbConnection.Table <CategoryDetailsModel>() where category.CategoryName == categoryName select category;
                    if (allCategories != null)
                    {
                        categoryObj = await allCategories.FirstOrDefaultAsync();
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }
            }
            else
            {
                Debug.WriteLine("failed to get sqlite connection");
            }
            return(categoryObj);
        }
Beispiel #5
0
        public async Task UpdateCategoryAsync(CategoryDetailsModel categoryModel)
        {
            if (_dbConnection != null)
            {
                try
                {
                    var allCategories = from category in _dbConnection.Table <CategoryDetailsModel>() where category.CategoryName.ToLower() == categoryModel.CategoryName.ToLower() select category;
                    if (allCategories != null)
                    {
                        CategoryDetailsModel tempCategory = await allCategories.FirstOrDefaultAsync();

                        if (tempCategory != null)
                        {
                            tempCategory.CategoryUrl    = categoryModel.CategoryUrl;
                            tempCategory.IsGroup        = categoryModel.IsGroup;
                            tempCategory.Order          = categoryModel.Order;
                            tempCategory.ParentCategory = categoryModel.ParentCategory;
                            tempCategory.IsWorking      = categoryModel.IsWorking;
                            await _dbConnection.UpdateAsync(tempCategory);
                        }
                        else
                        {
                            await _dbConnection.InsertAsync(categoryModel);
                        }
                    }
                    else
                    {
                        await _dbConnection.InsertAsync(categoryModel);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }
            }
            else
            {
                Debug.WriteLine("failed to get db connection");
            }
        }