public async Task <Models.Sample.Product> CancelProductChanges(Models.Sample.Product item)
        {
            var entity = context.Entry(item);

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

            return(item);
        }
        public async Task <Models.Sample.Product> CreateProduct(Models.Sample.Product product)
        {
            OnProductCreated(product);

            context.Products.Add(product);
            context.SaveChanges();

            return(product);
        }
        protected async System.Threading.Tasks.Task Form0Submit(BlazorCustomPaging.Models.Sample.Product args)
        {
            try
            {
                var sampleUpdateProductResult = await Sample.UpdateProduct(Id, product);

                DialogService.Close(product);
            }
            catch (Exception sampleUpdateProductException)
            {
                NotificationService.Notify(NotificationSeverity.Error, $"Error", $"Unable to update Product");
            }
        }
        public async Task <Models.Sample.Product> UpdateProduct(int?id, Models.Sample.Product product)
        {
            OnProductUpdated(product);

            var item = context.Products
                       .Where(i => i.Id == id)
                       .FirstOrDefault();

            if (item == null)
            {
                throw new Exception("Item no longer available");
            }
            var entry = context.Entry(item);

            entry.CurrentValues.SetValues(product);
            entry.State = EntityState.Modified;
            context.SaveChanges();

            return(product);
        }
 partial void OnProductUpdated(Models.Sample.Product item);
 partial void OnProductGet(Models.Sample.Product item);
 partial void OnProductDeleted(Models.Sample.Product item);
        protected async System.Threading.Tasks.Task Load()
        {
            var sampleGetProductByIdResult = await Sample.GetProductById(Id);

            product = sampleGetProductByIdResult;
        }
Example #9
0
 protected async System.Threading.Tasks.Task Load()
 {
     product = new BlazorCustomPaging.Models.Sample.Product()
     {
     };
 }
Example #10
0
        protected async System.Threading.Tasks.Task Grid0RowSelect(BlazorCustomPaging.Models.Sample.Product args)
        {
            var dialogResult = await DialogService.OpenAsync <EditProduct>("Edit Product", new Dictionary <string, object>() { { "Id", args.Id } });

            await InvokeAsync(() => { StateHasChanged(); });
        }