public void Create(DistributorCreate distributorCreate)
        {
            try
            {
                Distributor distributorToAdd = new Distributor
                {
                    IsLocked = false,
                    Counter  = 0,
                    //TankDistributors = new List<TankDistributor>()
                };

                _context.Add(distributorToAdd);
                _context.SaveChanges();

                //if (distributorCreate.TankIds == null) distributorCreate.TankIds = new List<int>();

                foreach (int tankId in distributorCreate.TankIds)
                {
                    TankDistributor td = _tankDistributorService.Create(tankId, distributorToAdd.DistributorId);
                    distributorToAdd.TankDistributors.Add(td);
                    _tankService.GetById(tankId).TankDistributors.Add(td);
                }

                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
 public IActionResult Create(DistributorCreate distributorCreate)
 {
     if (ModelState.IsValid)
     {
         _distributorService.Create(distributorCreate);
         TempData["Info"] = "Dytrybutor został dodany";
         return(RedirectToAction(nameof(Index)));
     }
     return(View(distributorCreate));
 }