示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }