public void DeleteItemAsync(Question question) { if (question.QuestionID != 0) { WriteOperations.Delete(db, question, true); //return db.UpdateAsync(question); } }
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(Question question) { if (question.QuestionID != 0) { WriteOperations.UpdateWithChildren(db, question); //return db.UpdateAsync(question); } else { WriteOperations.InsertWithChildren(db, question);//return db.InsertAsync(question); } }
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(); } }
//user public void SaveItemAsync(User user, bool isNewUser = false) { if (user != null) { if (isNewUser) { WriteOperations.InsertWithChildren(db, user); } else { WriteOperations.UpdateWithChildren(db, user); } } }
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); }
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; } } }
// Deletar produto public void DeleteProduct(Product product) { WriteOperations.Delete(sqliteconnection, product, false); }
// Deletar tudo public void DeleteAllProducts() { List <Product> products = GetProductList(); WriteOperations.DeleteAll(sqliteconnection, products); }
// Adicionar Produto public void InsertProduct(Product product) { WriteOperations.InsertWithChildren(sqliteconnection, product); }
// Atualizar Produto public void UpdateProduct(Product product) { WriteOperations.UpdateWithChildren(sqliteconnection, product); }
// Deletar tudo public void DeleteAllCategories() { List <Category> categories = GetCategories(); WriteOperations.DeleteAll(sqliteconnection, categories); }
// Atualizar categoria public void UpdateCategory(Category category) { WriteOperations.UpdateWithChildren(sqliteconnection, category); }
public void UpdateDepartment(Department department) { WriteOperations.UpdateWithChildren(connection, department); }
public Task DeleteMilestoneAsync(Milestone milestone) { return(WriteOperations.DeleteAsync(_asyncConnection, milestone, true)); }
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)); }
public Task SaveMilestoneAsync(Milestone milestone) { return(WriteOperations.InsertOrReplaceWithChildrenAsync(_asyncConnection, milestone)); }
public Task SaveAllMilestonesAsync(List <Milestone> milestones) { return(WriteOperations.InsertOrReplaceAllWithChildrenAsync(_asyncConnection, milestones)); }
// Adicionar categoria public void InsertCategory(Category category) { WriteOperations.InsertWithChildren(sqliteconnection, category); }
public void UpdateEmployee(Employee employee) { WriteOperations.UpdateWithChildren(connection, employee); }
// Deletar categoria public void DeleteCategory(Category category) { WriteOperations.Delete(sqliteconnection, category, false); }
public Task DeleteAllMilestonesAsync(List <Milestone> milestones) { return(WriteOperations.DeleteAllAsync(_asyncConnection, milestones)); }
public Task SaveUserChildAsync(Child child) { return(WriteOperations.InsertOrReplaceWithChildrenAsync(_asyncConnection, child)); }
public void RefreshDepartment(IList <Department> listDepartment) { WriteOperations.DeleteAll(connection, GetAllDepartment(), true); WriteOperations.InsertOrReplaceAllWithChildren(connection, listDepartment, true); }
public Task DeleteAllUserChildrenAsync(List <Child> children) { return(WriteOperations.DeleteAllAsync(_asyncConnection, children)); }
public void DeleteAllDepartment() { WriteOperations.DeleteAll(connection, GetAllDepartment(), true); }