public async Task <IActionResult> Create([Bind("CustomerId,CompanyName,VAT,StreetName,StreetNo,PostalCode,City,Country,PhoneNo,Email")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Create([Bind("JobId,JobName")] Job job) { if (ModelState.IsValid) { _context.Add(job); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(job)); }
public async Task <IActionResult> Create([Bind("HardwareId,HardwareName")] Hardware hardware) { if (ModelState.IsValid) { _context.Add(hardware); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hardware)); }
public async Task <IActionResult> Create([Bind("K_AdminId,CustomerId,FirstName,LastName,PhoneNo,Email")] K_Admin k_Admin) { if (ModelState.IsValid) { _context.Add(k_Admin); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CompanyName", k_Admin.CustomerId); return(View(k_Admin)); }
public async Task <IActionResult> Create([Bind("SubscriptionId,SubscriptionName,CustomerId,HardwareId")] Subscription subscription, string[] selectedK_Admins, string[] selectedJobs) { if (selectedK_Admins != null) { subscription.K_AdminSubscriptions = new List <K_AdminSubscriptions>(); foreach (var k_admin in selectedK_Admins) { var k_adminToAdd = new K_AdminSubscriptions { SubscriptionId = subscription.SubscriptionId, K_AdminId = int.Parse(k_admin) }; subscription.K_AdminSubscriptions.Add(k_adminToAdd); } } if (selectedJobs != null) { subscription.SubscriptionJobs = new List <SubscriptionJobs>(); foreach (var job in selectedJobs) { var jobToAdd = new SubscriptionJobs { SubscriptionId = subscription.SubscriptionId, JobId = int.Parse(job) }; subscription.SubscriptionJobs.Add(jobToAdd); } } if (ModelState.IsValid) { _context.Add(subscription); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CompanyName", subscription.CustomerId); //ViewData["HardwareId"] = new SelectList(_context.Hardware, "HardwareId", "HardwareName", subscription.HardwareId); PopulateCompanyDropDownList(subscription.CustomerId); PopulateHardwareDropDownList(subscription.HardwareId); PopulateAssignedK_AdminData(subscription); PopulateAssignedJobData(subscription); return(View(subscription)); }