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