Exemple #1
0
 public void DeleteItemAsync(Question question)
 {
     if (question.QuestionID != 0)
     {
         WriteOperations.Delete(db, question, true); //return db.UpdateAsync(question);
     }
 }
Exemple #2
0
        private string AddDataToMyDb()
        {
            using (var db = new SQLite.SQLiteConnection(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "bancoteste.db3")))
            {
                foreach (var item in ResultCategory)
                {
                    Categoria itemCategory = new Categoria
                    {
                        Id   = item.Id,
                        Name = item.Name
                    };
                    db.InsertOrReplace(itemCategory);
                }
                //int i = 0;
                foreach (var item in ResultPromotion)
                {
                    List <Policies> ListPolicies  = new List <Policies>();
                    Promotion       itemPromotion = new Promotion
                    {
                        //Id = null,
                        Name       = item.Name,
                        CategoryId = item.Category_id
                    };
                    foreach (var subItem in item.Policies)
                    {
                        Policies itemPolicies = new Policies
                        {
                            //Id = null,
                            Min      = subItem.Min,
                            Discount = subItem.Discount
                        };
                        db.InsertOrReplace(itemPolicies);
                        ListPolicies.Add(itemPolicies);
                    }
                    db.InsertOrReplace(itemPromotion);
                    itemPromotion.PoliciesId = ListPolicies;
                    WriteOperations.UpdateWithChildren(db, itemPromotion);
                    //db.
                }

                foreach (var item in ResultProduct)
                {
                    Product itemProduct = new Product
                    {
                        //Id = null,
                        Name        = item.Name,
                        Photo       = ConvertPngToJpeg(item.Photo),
                        Price       = item.Price,
                        Description = item.Description,
                        CategoryId  = item.Category_id
                    };
                    db.InsertOrReplace(itemProduct);
                }
            }
            return("terminou");
        }
Exemple #3
0
 public void SaveItemAsync(Question question)
 {
     if (question.QuestionID != 0)
     {
         WriteOperations.UpdateWithChildren(db, question); //return db.UpdateAsync(question);
     }
     else
     {
         WriteOperations.InsertWithChildren(db, question);//return db.InsertAsync(question);
     }
 }
Exemple #4
0
 public void SaveItemAsync(Answer answer)
 {
     if (answer.AnswerID != 0)
     {
         WriteOperations.UpdateWithChildren(db, answer); //return db.UpdateAsync(answer);
     }
     else
     {
         WriteOperations.InsertWithChildren(db, answer);  //return db.InsertAsync(answer);
     }
 }
        public static async Task SaveWeatherData(Weather weather)
        {
            if (weather != null && weather.IsValid())
            {
                await weatherDB.InsertOrReplaceAsync(weather);

                await WriteOperations.UpdateWithChildrenAsync(weatherDB, weather);
            }

            if (await weatherDB.Table <Weather>().CountAsync() > CACHE_LIMIT)
            {
                CleanupWeatherData();
            }
        }
Exemple #6
0
 //user
 public void SaveItemAsync(User user, bool isNewUser = false)
 {
     if (user != null)
     {
         if (isNewUser)
         {
             WriteOperations.InsertWithChildren(db, user);
         }
         else
         {
             WriteOperations.UpdateWithChildren(db, user);
         }
     }
 }
Exemple #7
0
        public async Task <int> SeveAsync(Debt debt)
        {
            int status = 0;

            if (debt.Id != 0)
            {
                status = await _databaseConnection.Database.UpdateAsync(debt);
            }
            else
            {
                status = await _databaseConnection.Database.InsertAsync(debt);
            }
            if (status >= 0)
            {
                await WriteOperations.UpdateWithChildrenAsync(_databaseConnection.Database, debt);
                await UpdateDebtsAsync();
            }
            return(status);
        }
Exemple #8
0
        public async Task UpdateDB(Category[] categories)
        {
            try
            {
                //because Categories from json haven't any id = haven't primary key.
                //So i should did it (that duplicates do not appear).
                await GetConnection().DeleteAllAsync <Category>();
                await GetConnection().DeleteAllAsync <Subject>();

                await WriteOperations.InsertOrReplaceAllWithChildrenAsync(GetConnection(), categories).ContinueWith(async(arg) =>
                {
                    Debug.WriteLine("[DataStorage.UpdateDB]: DB updated!");
                    await Delegate.DataBaseUdpated();
                });
            }
            catch (SQLiteException ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
        public override void Write(Chunk chunk)
        {
            int chunkId = chunk.Id;

            if (!WriteOperations.ContainsKey(chunkId))
            {
                WriteOperation writeOperation = new WriteOperation();
                WriteOperations.Add(chunkId, writeOperation);

                writeOperation.Run(chunk, Directory);
                //FLogger.Log(LogType.Message, "ChunkWriter: Writing " + chunk.FileName);
                //IOMessages.CurrentState = "Writing" + chunk.FileName;
            }
            else
            {
                WriteOperation writeOperation = (WriteOperation)WriteOperations[chunkId];
                if (writeOperation.IsCompleted)
                {
                    writeOperation.Run(chunk, Directory);
                    //FLogger.Log(LogType.Message, "ChunkWriter: ReWriting " + chunk.FileName);
                    //IOMessages.CurrentState = "ReWriting" + chunk.FileName;
                }
            }
        }
Exemple #10
0
 // Deletar produto
 public void DeleteProduct(Product product)
 {
     WriteOperations.Delete(sqliteconnection, product, false);
 }
Exemple #11
0
        // Deletar tudo
        public void DeleteAllProducts()
        {
            List <Product> products = GetProductList();

            WriteOperations.DeleteAll(sqliteconnection, products);
        }
Exemple #12
0
 // Adicionar Produto
 public void InsertProduct(Product product)
 {
     WriteOperations.InsertWithChildren(sqliteconnection, product);
 }
Exemple #13
0
 // Atualizar Produto
 public void UpdateProduct(Product product)
 {
     WriteOperations.UpdateWithChildren(sqliteconnection, product);
 }
Exemple #14
0
        // Deletar tudo
        public void DeleteAllCategories()
        {
            List <Category> categories = GetCategories();

            WriteOperations.DeleteAll(sqliteconnection, categories);
        }
Exemple #15
0
 // Atualizar categoria
 public void UpdateCategory(Category category)
 {
     WriteOperations.UpdateWithChildren(sqliteconnection, category);
 }
Exemple #16
0
 public void UpdateDepartment(Department department)
 {
     WriteOperations.UpdateWithChildren(connection, department);
 }
Exemple #17
0
 public Task DeleteMilestoneAsync(Milestone milestone)
 {
     return(WriteOperations.DeleteAsync(_asyncConnection, milestone, true));
 }
Exemple #18
0
 public Task DeleteUserChildAsync(Child child)
 {
     return(WriteOperations.DeleteAsync(_asyncConnection, child, true));
 }
 public Task DeleteVaccineAsync(Vaccine vaccine)
 {
     return(WriteOperations.DeleteAsync(_asyncConnection, vaccine, true));
 }
 public Task DeleteAllVaccinesAsync(List <Vaccine> vaccines)
 {
     return(WriteOperations.DeleteAllAsync(_asyncConnection, vaccines));
 }
Exemple #21
0
 public Task SaveMilestoneAsync(Milestone milestone)
 {
     return(WriteOperations.InsertOrReplaceWithChildrenAsync(_asyncConnection, milestone));
 }
Exemple #22
0
 public Task SaveAllMilestonesAsync(List <Milestone> milestones)
 {
     return(WriteOperations.InsertOrReplaceAllWithChildrenAsync(_asyncConnection, milestones));
 }
Exemple #23
0
 // Adicionar categoria
 public void InsertCategory(Category category)
 {
     WriteOperations.InsertWithChildren(sqliteconnection, category);
 }
Exemple #24
0
 public void UpdateEmployee(Employee employee)
 {
     WriteOperations.UpdateWithChildren(connection, employee);
 }
Exemple #25
0
 // Deletar categoria
 public void DeleteCategory(Category category)
 {
     WriteOperations.Delete(sqliteconnection, category, false);
 }
Exemple #26
0
 public Task DeleteAllMilestonesAsync(List <Milestone> milestones)
 {
     return(WriteOperations.DeleteAllAsync(_asyncConnection, milestones));
 }
Exemple #27
0
 public Task SaveUserChildAsync(Child child)
 {
     return(WriteOperations.InsertOrReplaceWithChildrenAsync(_asyncConnection, child));
 }
Exemple #28
0
 public void RefreshDepartment(IList <Department> listDepartment)
 {
     WriteOperations.DeleteAll(connection, GetAllDepartment(), true);
     WriteOperations.InsertOrReplaceAllWithChildren(connection, listDepartment, true);
 }
Exemple #29
0
 public Task DeleteAllUserChildrenAsync(List <Child> children)
 {
     return(WriteOperations.DeleteAllAsync(_asyncConnection, children));
 }
Exemple #30
0
 public void DeleteAllDepartment()
 {
     WriteOperations.DeleteAll(connection, GetAllDepartment(), true);
 }