Exemple #1
0
        private async void OnSave(object obj)
        {
            IsBusy = true;

            try
            {
                // Thuc hien cong viec tai day
                var itemLogic = new ItemLogic(_dbContext);
                var item      = new Item
                {
                    Id          = ItemBindProp.Id,
                    ItemName    = ItemBindProp.Name,
                    FkCategory  = CategoryBindProp.Id,
                    Price       = ItemBindProp.Value,
                    IsManaged   = IsManaged == true ? 1 : 0,
                    MinQuantity = MinQuantityBindProp,
                    ItemImage   = ImagePathBindProp
                };
                ItemBindProp.FkCategory = CategoryBindProp.Id;
                ItemBindProp.ItemImage  = ImagePathBindProp;
                if (IsEditing)
                {
                    await itemLogic.UpdateAsync(item);

                    await NavigationService.GoBackAsync();
                }
                else
                {
                    await itemLogic.CreateAsync(item);

                    var param = new NavigationParameters();
                    param.Add(Keys.ITEM, ItemBindProp);

                    await NavigationService.GoBackAsync(param);
                }
            }
            catch (Exception e)
            {
                await ShowError(e);
            }
            finally
            {
                IsBusy = false;
            }
        }