public async Task <IActionResult> AssignCompany(AssignCompanyModel aCM)
        {
            if (ModelState.IsValid)
            {
                var newFirma = new Firma()
                {
                    IdFirma = aCM.firma.IdFirma,
                    Nazwa   = aCM.firma.Nazwa
                };

                _s16693context.Add(newFirma);
                await _s16693context.SaveChangesAsync();

                var newKF = new KlientFirma()
                {
                    IdKlient = aCM.klient.IdKlient,
                    IdFirma  = newFirma.IdFirma
                };

                _s16693context.Add(newKF);

                await _s16693context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else if (!ModelState.IsValid)
            {
                return(View("AssignCompany", aCM));
            }
            return(View(aCM));
        }
        public async Task <IActionResult> ProjectCreate(ProjectCreateModel pCM)
        {
            if (ModelState.IsValid)
            {
                var fileName = Path.Combine(hostingEnvironment.WebRootPath + "/images", Path.GetFileName(pCM.FormFile.FileName));
                pCM.FormFile.CopyTo(new FileStream(fileName, FileMode.Create));

                var newProjekt = new Projekt()
                {
                    Nazwa   = pCM.projekt.Nazwa,
                    Logo    = "images/" + Path.GetFileName(pCM.FormFile.FileName),
                    IdFirma = pCM.projekt.IdFirma
                };

                _s16693context.Add(newProjekt);
                await _s16693context.SaveChangesAsync();

                var newZP = new ZespolProjekt()
                {
                    IdProjekt = newProjekt.IdProjekt,
                    IdZespol  = (int)pCM.zespol.IdZespol,
                    DataPrzypisaniaZespolu = DateTime.Now
                };

                var newPP = new ProjektPakiet()
                {
                    IdProjekt = newProjekt.IdProjekt,
                    IdPakiet  = (int)pCM.pakiet.IdPakiet,
                    DataRozpoczeciaWspolpracy = DateTime.Now
                };

                _s16693context.Add(newZP);
                _s16693context.Add(newPP);

                await _s16693context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else if (!ModelState.IsValid)
            {
                var firma  = from e in _s16693context.Firma select e;
                var zespol = from e in _s16693context.Zespol select e;
                var pakiet = from e in _s16693context.Pakiet select e;

                pCM.zespols = await zespol.ToListAsync();

                pCM.pakiets = await pakiet.ToListAsync();

                pCM.firmas = await firma.ToListAsync();

                return(View("ProjectCreate", pCM));
            }
            return(View(pCM));
        }