public async Task <Models.SimpleInvoice.Product> CancelProductChanges(Models.SimpleInvoice.Product item) { var entityToCancel = Context.Entry(item); entityToCancel.CurrentValues.SetValues(entityToCancel.OriginalValues); entityToCancel.State = EntityState.Unchanged; return(item); }
public async Task <Models.SimpleInvoice.Product> CreateProduct(Models.SimpleInvoice.Product product) { OnProductCreated(product); Context.Products.Add(product); Context.SaveChanges(); OnAfterProductCreated(product); return(product); }
protected async System.Threading.Tasks.Task Form0Submit(SimpleInvoiceManagementSoftware.Models.SimpleInvoice.Product args) { try { var simpleInvoiceUpdateProductResult = await SimpleInvoice.UpdateProduct(ProductId, product); DialogService.Close(product); } catch (System.Exception simpleInvoiceUpdateProductException) { NotificationService.Notify(new NotificationMessage() { Severity = NotificationSeverity.Error, Summary = $"Error", Detail = $"Unable to update Product" }); } }
public void DataInitialization() { var company = Context.Companies.FirstOrDefault(); if (company == null) { company = new Models.SimpleInvoice.Company(); company.Name = "YourCompany, Inc."; company.Description = "My next great company."; company.Address = "1st Pajajaran Street."; company.City = "Bandung City."; Context.Companies.Add(company); var customer = new Models.SimpleInvoice.Customer(); customer.Name = "Default Customer"; customer.Description = "My best loyal customer"; customer.Address = "1st Sudirman Street."; customer.City = "Jakarta City."; Context.Customers.Add(customer); var officeBasic = new Models.SimpleInvoice.Product(); officeBasic.Name = "Basic, MS Office 365."; officeBasic.UnitPrice = 50; var officeStandard = new Models.SimpleInvoice.Product(); officeStandard.Name = "Standard, MS Office 365."; officeStandard.UnitPrice = 100; var officePremium = new Models.SimpleInvoice.Product(); officePremium.Name = "Premium, MS Office 365."; officePremium.UnitPrice = 200; Context.Products.AddRange(officeBasic, officeStandard, officePremium); var tax = new Models.SimpleInvoice.Tax(); tax.Name = "VAT"; tax.TaxTariffPercentage = 10; Context.Taxes.Add(tax); Context.SaveChanges(); } }
public async Task <Models.SimpleInvoice.Product> UpdateProduct(int?productId, Models.SimpleInvoice.Product product) { OnProductUpdated(product); var itemToUpdate = Context.Products .Where(i => i.ProductId == productId) .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); }
partial void OnAfterProductUpdated(Models.SimpleInvoice.Product item);
partial void OnProductGet(Models.SimpleInvoice.Product item);
partial void OnProductDeleted(Models.SimpleInvoice.Product item);
protected async System.Threading.Tasks.Task Load() { var simpleInvoiceGetProductByProductIdResult = await SimpleInvoice.GetProductByProductId(ProductId); product = simpleInvoiceGetProductByProductIdResult; }
protected async System.Threading.Tasks.Task Load() { product = new SimpleInvoiceManagementSoftware.Models.SimpleInvoice.Product() { }; }
protected async System.Threading.Tasks.Task Grid0RowSelect(SimpleInvoiceManagementSoftware.Models.SimpleInvoice.Product args) { var dialogResult = await DialogService.OpenAsync <EditProduct>("Edit Product", new Dictionary <string, object>() { { "ProductId", args.ProductId } }); await InvokeAsync(() => { StateHasChanged(); }); }