public void Delete(T entity) { if (entity == null) { throw new ArgumentNullException("entity"); } entities.Remove(entity); _context.SaveChanges(); }
private void addBtn_Click(object sender, EventArgs e) { InvoiceItem ii = new InvoiceItem(); ii.Product = productListBox.SelectedItem as Product; ii.Quantity = Convert.ToInt32(amountTextBox.Text); ii.InvoiceID = maxNumber; addedListBox.Items.Add(ii); ShowListAdded(); InvoiceDbContext.InvoiceItems.Add(ii); InvoiceDbContext.SaveChanges(); }
public void AddInvoice(IInvoice invoice) { InvoiceMaster master = new InvoiceMaster { InvoiceId = invoice.InvoiceId, InvoiceName = invoice.InvoiceName, IsActive = invoice.IsActive }; _invoiceDbContext.InvoiceMaster.Add(master); foreach (var rule in invoice.Rules) { var rd = new RuleDetails { RuleValue = rule.RuleValue, InvoiceId = master.InvoiceId, ParameterId = rule.ParameterId, IsActive = rule.IsActive }; _invoiceDbContext.RuleDetails.Add(rd); } _invoiceDbContext.SaveChanges(); }
public void Actualizar(T entity, int id) { if (entity == null) { throw new ArgumentException("Entity"); } T existe = entities.Find(id); if (existe != null) { _context.Entry(existe).CurrentValues.SetValues(entity); _context.SaveChanges(); } _context.SaveChanges(); }
public void Seed(InvoiceDbContext context, UserManager <User> userManager) { // TODO Working? User user = new User(); user.UserName = "******"; user.Email = "Admin@admin"; IdentityResult result = userManager.CreateAsync(user, "Zaq123$").Result; this.SeedData(context, userManager); context.SaveChanges(); }
/// <summary> /// This method saves and updates the user information based on the user object passed /// </summary> /// <param name="user"></param> public void SaveUser(User user) { if (user.UserId == 0) { _dbContext.Users.Add(user); } else { User userEntity = _dbContext.Users.Find(user.UserName); userEntity.Change(user); } _dbContext.SaveChanges(); }
public IActionResult AddNir([FromBody] NirModel model) { if (ModelState.IsValid) { nirRepository.Insert(model); foreach (NirItemsModel prod in model.Items) { var incProdStoc = productRepository.All().FirstOrDefault(product => product.Name == prod.Name); incProdStoc.Stoc += prod.Quantity; _context.SaveChanges(); } return(Json(new { error = false, message = "Sales saved successfully" })); } return(Json(new { error = true, message = "failed to save Sales" })); }
public void CreateCustomer(Customer cust) { _context.Customers.Add(cust); _context.SaveChanges(); }
public void PostInvoice(Invoice inv) { _context.Invoices.Add(inv); _context.SaveChanges(); }
public void CreateProduct(Product product) { _context.Products.Add(product); _context.SaveChanges(); }