Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Country country)
        {
            if (ModelState.IsValid)
            {
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Name,Passport,Year,Id,Education")] Employer employer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employer));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Name,Year,Id")] ItCompany itCompany)
        {
            if (ModelState.IsValid)
            {
                _context.Add(itCompany);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(itCompany));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Position")] EmpPosition empPosition)
        {
            if (ModelState.IsValid)
            {
                _context.Add(empPosition);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empPosition));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Name,Year,Budget,ItCompanyId,Id")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ItCompanyId"] = new SelectList(_context.ItCompanies, "Id", "Name", product.ItCompanyId);
            return(View(product));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Name,OfficeId")] Subdivision subdivision)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subdivision);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OfficeId"] = new SelectList(_context.Offices, "Id", "Address", subdivision.OfficeId);
            return(View(subdivision));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,CityId,Square,Address,ItCompanyId")] Office office)
        {
            if (ModelState.IsValid)
            {
                _context.Add(office);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"]      = new SelectList(_context.Cities, "Id", "Name", office.CityId);
            ViewData["ItCompanyId"] = new SelectList(_context.ItCompanies, "Id", "Name", office.ItCompanyId);
            return(View(office));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Id,Salary,PositionId,SubdivisionId,EmployerId")] EmpSub empSub)
        {
            if (ModelState.IsValid)
            {
                _context.Add(empSub);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployerId"]    = new SelectList(_context.Employers, "Id", "Name", empSub.EmployerId);
            ViewData["PositionId"]    = new SelectList(_context.Positions, "Id", "Position", empSub.PositionId);
            ViewData["SubdivisionId"] = new SelectList(_context.Subdivisions, "Id", "Name", empSub.SubdivisionId);
            return(View(empSub));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create(int countryId, [Bind("Id,Name")] City city)
        {
            city.CountryId = countryId;
            if (ModelState.IsValid)
            {
                _context.Add(city);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Cities", new { id = countryId, name = _context.Countries.Where(c => c.Id == countryId).FirstOrDefault().Name }));
            }
            //ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Name", city.CountryId);
            //return View(city);
            return(RedirectToAction("Index", "Cities", new { id = countryId, name = _context.Countries.Where(c => c.Id == countryId).FirstOrDefault().Name }));
        }