示例#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);
        }
示例#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!"
                });
            }
        }
示例#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()
     {
     };
 }
示例#7
0
 partial void OnAfterProductCreated(Models.SampleDb.Product item);
示例#8
0
 partial void OnProductUpdated(Models.SampleDb.Product item);
示例#9
0
 partial void OnProductGet(Models.SampleDb.Product item);
示例#10
0
 partial void OnProductDeleted(Models.SampleDb.Product item);
        protected async System.Threading.Tasks.Task Load()
        {
            var sampleDbGetProductByIdResult = await SampleDb.GetProductById(Id);

            product = sampleDbGetProductByIdResult;
        }