protected async System.Threading.Tasks.Task Grid0RowSelect(Flashcardgenerator.Models.Localhost.Category args)
        {
            var dialogResult = await DialogService.OpenAsync <EditCategory>("Edit Category", new Dictionary <string, object>() { { "categoryId", args.categoryId } });

            await grid0.Reload();

            await InvokeAsync(() => { StateHasChanged(); });
        }
        public async Task <Models.Localhost.Category> CancelCategoryChanges(Models.Localhost.Category item)
        {
            var entityToCancel = Context.Entry(item);

            entityToCancel.CurrentValues.SetValues(entityToCancel.OriginalValues);
            entityToCancel.State = EntityState.Unchanged;

            return(item);
        }
예제 #3
0
        protected async System.Threading.Tasks.Task Load()
        {
            hasChanges = false;

            canEdit = true;

            var localhostGetCategoryBycategoryIdResult = await Localhost.GetCategoryBycategoryId(categoryId);

            category = localhostGetCategoryBycategoryIdResult;
        }
        public async Task <Models.Localhost.Category> CreateCategory(Models.Localhost.Category category)
        {
            OnCategoryCreated(category);

            Context.Categories.Add(category);
            Context.SaveChanges();

            OnAfterCategoryCreated(category);

            return(category);
        }
        protected async System.Threading.Tasks.Task Form0Submit(Flashcardgenerator.Models.Localhost.Category args)
        {
            try
            {
                var localhostCreateCategoryResult = await Localhost.CreateCategory(category);

                DialogService.Close(category);
            }
            catch (System.Exception localhostCreateCategoryException)
            {
                NotificationService.Notify(new NotificationMessage()
                {
                    Severity = NotificationSeverity.Error, Summary = $"Error", Detail = $"Unable to create new Category!"
                });
            }
        }
        public async Task <Models.Localhost.Category> UpdateCategory(int?categoryId, Models.Localhost.Category category)
        {
            OnCategoryUpdated(category);

            var itemToUpdate = Context.Categories
                               .Where(i => i.categoryId == categoryId)
                               .FirstOrDefault();

            if (itemToUpdate == null)
            {
                throw new Exception("Item no longer available");
            }
            var entryToUpdate = Context.Entry(itemToUpdate);

            entryToUpdate.CurrentValues.SetValues(category);
            entryToUpdate.State = EntityState.Modified;
            Context.SaveChanges();

            OnAfterCategoryUpdated(category);

            return(category);
        }
 protected async System.Threading.Tasks.Task Load()
 {
     category = new Flashcardgenerator.Models.Localhost.Category()
     {
     };
 }
 partial void OnAfterCategoryUpdated(Models.Localhost.Category item);
 partial void OnCategoryGet(Models.Localhost.Category item);
 partial void OnCategoryDeleted(Models.Localhost.Category item);