Beispiel #1
0
        public async Task <Models.SampleDb.Product> CancelProductChanges(Models.SampleDb.Product item)
        {
            var entityToCancel = context.Entry(item);

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

            return(item);
        }
Beispiel #2
0
        public async Task <Models.SampleDb.Product> CreateProduct(Models.SampleDb.Product product)
        {
            OnProductCreated(product);

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

            OnAfterProductCreated(product);

            return(product);
        }
        protected async System.Threading.Tasks.Task Form0Submit(ExportOperations.Models.SampleDb.Product args)
        {
            try
            {
                var sampleDbCreateProductResult = await SampleDb.CreateProduct(product);

                DialogService.Close(product);
            }
            catch (System.Exception sampleDbCreateProductException)
            {
                NotificationService.Notify(new NotificationMessage()
                {
                    Severity = NotificationSeverity.Error, Summary = $"Error", Detail = $"Unable to create new Product!"
                });
            }
        }
Beispiel #4
0
        public async Task <Models.SampleDb.Product> UpdateProduct(int?id, Models.SampleDb.Product product)
        {
            OnProductUpdated(product);

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

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

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

            OnAfterProductUpdated(product);

            return(product);
        }
        protected async System.Threading.Tasks.Task Grid0RowSelect(ExportOperations.Models.SampleDb.Product args)
        {
            var dialogResult = await DialogService.OpenAsync <EditProduct>("Edit Product", new Dictionary <string, object>() { { "Id", args.Id } });

            await InvokeAsync(() => { StateHasChanged(); });
        }
 protected async System.Threading.Tasks.Task Load()
 {
     product = new ExportOperations.Models.SampleDb.Product()
     {
     };
 }
Beispiel #7
0
 partial void OnAfterProductCreated(Models.SampleDb.Product item);
Beispiel #8
0
 partial void OnProductUpdated(Models.SampleDb.Product item);
Beispiel #9
0
 partial void OnProductGet(Models.SampleDb.Product item);
Beispiel #10
0
 partial void OnProductDeleted(Models.SampleDb.Product item);
        protected async System.Threading.Tasks.Task Load()
        {
            var sampleDbGetProductByIdResult = await SampleDb.GetProductById(Id);

            product = sampleDbGetProductByIdResult;
        }