public IActionResult Add(AddExpenseViewModel addExpenseViewModel) { if (ModelState.IsValid) { ExpenseCategory newCategory = context.ExpenseCategories.Single(c => c.ID == addExpenseViewModel.ExpenseCategoryID); // Add the new cheese to my existing cheeses Expense newExpense = new Expense { Date = addExpenseViewModel.Date, Reference = addExpenseViewModel.Reference, Owner = addExpenseViewModel.Owner, Description = addExpenseViewModel.Description, Amount = addExpenseViewModel.Amount, ExpenseCategory = newCategory }; context.Expenses.Add(newExpense); context.SaveChanges(); return(Redirect("/Expense")); } return(View(addExpenseViewModel)); }
public IActionResult Add(AddDriverLoadViewModel addDriverLoadViewModel) { if (ModelState.IsValid) { DriverName newDriver = context.DriverNames.Single(c => c.ID == addDriverLoadViewModel.DriverNameID); // Add the new cheese to my existing cheeses Driver newTrip = new Driver { Date = addDriverLoadViewModel.Date, Reference = addDriverLoadViewModel.Reference, Description = addDriverLoadViewModel.Description, LoadMiles = addDriverLoadViewModel.LoadMiles, DeadMiles = addDriverLoadViewModel.DeadMiles, Rate = addDriverLoadViewModel.Rate, DriverName = newDriver }; context.Drivers.Add(newTrip); context.SaveChanges(); return(Redirect("/Driver")); } return(View(addDriverLoadViewModel)); }
public IActionResult Add(AddLoadViewModel addLoadViewModel) { if (ModelState.IsValid) { LoadCategory newLoadCategory = context.LoadCategories.Single(c => c.ID == addLoadViewModel.LoadCategoryID); Load newLoad = new Load { Date = addLoadViewModel.Date, Reference = addLoadViewModel.Reference, Description = addLoadViewModel.Description, Owner = addLoadViewModel.Owner, Amount = addLoadViewModel.Amount, LoadCategory = newLoadCategory, }; context.Loads.Add(newLoad); context.SaveChanges(); return(Redirect("/Load")); } return(View(addLoadViewModel)); }
public IActionResult Add(AddOwnerViewModel addOwnerViewModel) { if (ModelState.IsValid) { Owner newOwner = new Owner { Name = addOwnerViewModel.Name }; context.Owners.Add(newOwner); context.SaveChanges(); return(Redirect("/Owner")); } return(View(addOwnerViewModel)); }
public IActionResult Add(AddLoadCategoryViewModel addLoadCategoryViewModel) { if (ModelState.IsValid) { LoadCategory newLoadCategory = new LoadCategory { Name = addLoadCategoryViewModel.Name, }; context.LoadCategories.Add(newLoadCategory); context.SaveChanges(); return(Redirect("/LoadCategory")); } return(View(addLoadCategoryViewModel)); }
public IActionResult Add(AddDriverNameViewModel addDriverNameViewModel) { if (ModelState.IsValid) { DriverName newDriverName = new DriverName { Name = addDriverNameViewModel.Name, }; context.DriverNames.Add(newDriverName); context.SaveChanges(); return(Redirect("/DriverName")); } return(View(addDriverNameViewModel)); }