public async Task <Seller> CreateSellerAsync(Seller seller) { await _salesManagementContext.AddAsync(seller); await _salesManagementContext.SaveChangesAsync(); return(seller); }
public async Task <Sale> CreateSaleAsync(Sale sale) { await _salesManagementContext.AddAsync(sale); await _salesManagementContext.SaveChangesAsync(); return(sale); }
public async Task <IActionResult> Create([Bind("Id,Name")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Create([Bind("Id,FullName")] SalesPerson salesPerson) { if (ModelState.IsValid) { salesPerson.Sales = new List <Sale>(); salesPerson.Commission = 0; _context.Add(salesPerson); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(salesPerson)); }
public async Task <IActionResult> Create([Bind("SaleId,SalesPersonFullName,Amount,Date")] Sale sale) { if (ModelState.IsValid) { SalesPerson employee = await _context.SalesPeople.Include(sp => sp.Sales) .FirstOrDefaultAsync(sp => sp.FullName == sale.SalesPersonFullName); sale.SalesEmployee = employee; _context.Add(sale); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SalesPersonFullName"] = new SelectList(_context.SalesPeople, "FullName", "FullName", sale.SalesPersonFullName); return(View(sale)); }
public async Task Insert(Seller obj) { _context.Add(obj); await _context.SaveChangesAsync(); }