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