public async Task <IActionResult> Create(IList <AddTreatmentViewModel> model)
        {
            if (ManagedYearPlan == null)
            {
                return(ActionIfNotChoosedManagedYearPlan());
            }
            if (!ModelState.IsValid)
            {
                var kinds = await _treatmentKindRepository.GetAll();

                var fields = await _fieldRepository.GetByYearPlan(ManagedYearPlan);

                var fertilizers = await _fertilizerRepository.GetAll();

                var KindList       = new SelectList(kinds, "Id", "Name");
                var FieldList      = new SelectList(fields, "Id", "Name");
                var FertilizerList = new SelectList(fertilizers, "Id", "Name");

                ViewBag.Kinds       = KindList;
                ViewBag.Fields      = FieldList;
                ViewBag.Fertilizers = FertilizerList;
                return(View(model));
            }

            var treatments = model.Select((x) => new Treatment
            {
                Date          = x.Date,
                Notes         = x.Notes,
                DosePerHa     = x.DosePerHa,
                Composition   = x.SprayingAgents,
                ReasonForUse  = x.ReasonForUse,
                Field         = _fieldRepository.GetById(x.FieldId).Result,
                Fertilizer    = _fertilizerRepository.GetById(x.FertilizerId).Result,
                TreatmentKind = _treatmentKindRepository.GetById(x.TreatmentKindId).Result
            });
            await _treatmentRepository.AddRange(treatments);

            TempData["message"] = "Pomyślnie dodano nowe zabiegi";
            return(RedirectToAction("Index"));
        }