Example #1
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");
        }
Example #2
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);
     }
 }
Example #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);
     }
 }
Example #4
0
 //user
 public void SaveItemAsync(User user, bool isNewUser = false)
 {
     if (user != null)
     {
         if (isNewUser)
         {
             WriteOperations.InsertWithChildren(db, user);
         }
         else
         {
             WriteOperations.UpdateWithChildren(db, user);
         }
     }
 }
Example #5
0
 // Atualizar Produto
 public void UpdateProduct(Product product)
 {
     WriteOperations.UpdateWithChildren(sqliteconnection, product);
 }
Example #6
0
 // Atualizar categoria
 public void UpdateCategory(Category category)
 {
     WriteOperations.UpdateWithChildren(sqliteconnection, category);
 }
Example #7
0
 public void UpdateEmployee(Employee employee)
 {
     WriteOperations.UpdateWithChildren(connection, employee);
 }
Example #8
0
 public void UpdateDepartment(Department department)
 {
     WriteOperations.UpdateWithChildren(connection, department);
 }