private void UpdateCurrentCategory2() { if (_categories != null && _currentCategoryId != null) { CurrentCategory = _categories.FirstOrDefault(cat => cat.Id == _currentCategoryId); } else { CurrentCategory = null; } }
private static void UpdateFldDscs(Category target, IList<FieldDescription> allFldDscs) { if (target != null) { // populate FieldDescriptions List<FieldDescription> newFldDscs = new List<FieldDescription>(); foreach (var fldDscId in target._fieldDescriptionIds) { var newFldDsc = allFldDscs.FirstOrDefault(fd => fd.Id == fldDscId); if (newFldDsc != null) newFldDscs.Add(newFldDsc); } //if (target.FieldDescriptions == null) target._fieldDescriptions = new SwitchableObservableCollection<FieldDescription>(); target.FieldDescriptions.ReplaceAll(newFldDscs); } }
internal static void Copy(Category source, ref Category target, IList<FieldDescription> allFldDscs) { if (source != null && target != null) { target._fieldDescriptionIds.ReplaceAll(source._fieldDescriptionIds); UpdateFldDscs(target, allFldDscs); //// populate FieldDescriptions //List<FieldDescription> newFldDscs = new List<FieldDescription>(); //foreach (var fldDscId in source._fieldDescriptionIds) //{ // var newFldDsc = allFldDscs.FirstOrDefault(fd => fd.Id == fldDscId); // if (newFldDsc != null) newFldDscs.Add(newFldDsc); //} //target.FieldDescriptions.ReplaceAll(newFldDscs); target.Id = source.Id; target.IsCustom = source.IsCustom; // target.IsJustAdded = source.IsJustAdded; // no! target.Name = source.Name; } }
public Task SetCurrentCategoryAsync(Category newItem) { return RunFunctionIfOpenAsyncT(async delegate { var mbc = _briefcase?.MetaBriefcase; if (mbc == null) return; await mbc.SetCurrentCategoryAsync(newItem); await UpdateAssignedUnassignedFieldsAsync().ConfigureAwait(false); }); }
public async Task<bool> RemoveCategoryAsync(Category cat) { var mbc = _briefcase?.MetaBriefcase; if (mbc == null) return false; return await RunFunctionIfOpenAsyncTB(() => mbc.RemoveCategoryAsync(cat)).ConfigureAwait(false); }
internal void RemoveFromJustAssignedToCats(Category cat) { if (cat?.Id != null && _justAssignedToCats != null && _justAssignedToCats.Contains(cat.Id)) { _justAssignedToCats.Remove(cat.Id); RaisePropertyChanged_UI(nameof(JustAssignedToCats)); // in case someone wants to bind to it } }
public Task<bool> RemoveCategoryAsync(Category cat) { return RunFunctionIfOpenAsyncTB(async delegate { if (cat != null && (cat.IsJustAdded || IsElevated)) { bool isRemoved = false; await RunInUiThreadAsync(() => isRemoved = _categories.Remove(cat)).ConfigureAwait(false); await _rubbishBin.AddCategoryAsync(cat); if (CurrentCategoryId == cat.Id && _categories.Any()) CurrentCategoryId = _categories[0]?.Id; return isRemoved; } else { return false; } }); }
private async Task<bool> AddCategory2Async(Category newCat) { if (Category.Check(newCat) && !Categories.Any(cat => cat.Name == newCat.Name || cat.Id == newCat.Id)) { await RunInUiThreadAsync(() => _categories.Add(newCat)).ConfigureAwait(false); return true; } return false; }
public Task<bool> AddCategoryAsync(Category newCat) { return RunFunctionIfOpenAsyncTB(delegate { return AddCategory2Async(newCat); }); }
public Task<bool> AddNewCategoryAsync() { return RunFunctionIfOpenAsyncTB(delegate { string name = RuntimeData.GetText("NewCategory"); var newCat = new Category(name, true, true); return AddCategory2Async(newCat); }); }
public Task SetCurrentCategoryAsync(Category cat) { return RunFunctionIfOpenAsyncA(delegate { if (cat != null) { CurrentCategoryId = cat.Id; } }); }
private List<Tuple<FieldDescription, FieldValue>> DeletedFieldValues { get { return _deletedFieldValues; } set { _deletedFieldValues = value; } } // the setter is only for the serialiser internal Task AddCategoryAsync(Category category) { if (category == null) return Task.CompletedTask; return RunFunctionIfOpenAsyncA(() => { _deletedCategories.RemoveAll(cat => cat.Name == category.Name); _deletedCategories.Add(category); }); }
public static void Copy(SwitchableObservableCollection<Category> source, ref SwitchableObservableCollection<Category> target, IList<FieldDescription> allFldDscs) { if (source != null && target != null) { target.IsObserving = false; target.Clear(); foreach (var sourceRecord in source) { var targetRecord = new Category(); Copy(sourceRecord, ref targetRecord, allFldDscs); target.Add(targetRecord); } target.IsObserving = true; } }
public static bool Check(Category cat) { return cat != null && cat.Id != DEFAULT_ID && cat.FieldDescriptions != null && cat.FieldDescriptionIds != null && !string.IsNullOrWhiteSpace(cat.Name); }
public static void Copy(IList<Category> source, ref List<Category> target, IList<FieldDescription> allFldDscs) { if (source != null && target != null) { target.Clear(); foreach (var sourceRecord in source) { var targetRecord = new Category(); Copy(sourceRecord, ref targetRecord, allFldDscs); target.Add(targetRecord); } } }