Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CompanyId,EmployeeId")] CompanyEmployeeRegistration companyEmployeeRegistration)
        {
            if (id != companyEmployeeRegistration.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companyEmployeeRegistration);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyEmployeeRegistrationExists(companyEmployeeRegistration.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompanyId"]  = new SelectList(_context.Company, "Id", "Id", companyEmployeeRegistration.CompanyId);
            ViewData["EmployeeId"] = new SelectList(_context.Set <Employee>(), "Id", "Id", companyEmployeeRegistration.EmployeeId);
            return(View(companyEmployeeRegistration));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,CompanyId,EmployeeId")] CompanyEmployeeRegistration companyEmployeeRegistration)
        {
            if (ModelState.IsValid)
            {
                _context.Add(companyEmployeeRegistration);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompanyId"]  = new SelectList(_context.Company, "Id", "Id", companyEmployeeRegistration.CompanyId);
            ViewData["EmployeeId"] = new SelectList(_context.Set <Employee>(), "Id", "Id", companyEmployeeRegistration.EmployeeId);
            return(View(companyEmployeeRegistration));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CompanyEmployeeRegistration = await _context.CompanyEmployeeRegistration.FindAsync(id);

            if (CompanyEmployeeRegistration != null)
            {
                _context.CompanyEmployeeRegistration.Remove(CompanyEmployeeRegistration);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CompanyEmployeeRegistration = await _context.CompanyEmployeeRegistration
                                          .Include(c => c.Company)
                                          .Include(c => c.Employee).FirstOrDefaultAsync(m => m.Id == id);

            if (CompanyEmployeeRegistration == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CompanyEmployeeRegistration = await _context.CompanyEmployeeRegistration
                                          .Include(c => c.Company)
                                          .Include(c => c.Employee).FirstOrDefaultAsync(m => m.Id == id);

            if (CompanyEmployeeRegistration == null)
            {
                return(NotFound());
            }
            ViewData["CompanyId"]  = new SelectList(_context.Set <Company>(), "Id", "Name");
            ViewData["EmployeeId"] = new SelectList(_context.Set <Employee>(), "Id", "Name");
            return(Page());
        }