Esempio n. 1
0
        public async Task UpdateOrAddCategoryAsync(Category s, CategoryKeepActive keepIsActive)
        {
            List <Category> results = await database.QueryAsync <Category>("select * from Category where Name='" + s.Name + "'");

            Category current = results.FirstOrDefault <Category>();

            if (current != null)
            {
                // If we want to retain the current IsActive flag, copy it from the current record
                // before doing an update.
                if (keepIsActive == CategoryKeepActive.Keep)
                {
                    s.IsActive = current.IsActive;
                }

                await database.UpdateAsync(s);
            }
            else
            {
                await database.InsertAsync(s);
            }
        }
Esempio n. 2
0
        public async Task UpdateOrAddCategoryAsync(Category s, CategoryKeepActive keepIsActive)
        {            
            List<Category> results = await database.QueryAsync<Category>("select * from Category where Name='" + s.Name + "'");
            Category current = results.FirstOrDefault<Category>();

            if (current != null)
            {
                // If we want to retain the current IsActive flag, copy it from the current record
                // before doing an update.
                if (keepIsActive == CategoryKeepActive.Keep)
                {
                    s.IsActive = current.IsActive;
                }

                await database.UpdateAsync(s);
            }
            else
            {
                await database.InsertAsync(s);
            }
        }