public async Task <IActionResult> Index() { if (ManagedYearPlan == null) { return(ActionIfNotChoosedManagedYearPlan()); } var treatments = await _treatmentRepository.GetAllByYearPlan(ManagedYearPlan); var model = treatments.Select(x => new TreatmentViewModel { Id = x.Id, Name = x.TreatmentKind.Name, Date = x.Date, Notes = x.Notes, DosePerHa = x.DosePerHa.ToString(), SprayingAgents = x.Composition, ReasonForUse = x.ReasonForUse, FieldName = x.Field.Name, FertilizerName = x.Fertilizer?.Name, }); return(View(model.OrderByDescending(x => x.Date))); }