Пример #1
0
 public IActionResult AddSowing(NewSowingVm model)
 {
     //sprawdzic czy nie ma nowszego zabiegu.
     if (ModelState.IsValid)
     {
         var sowingId = _sowingService.AddSowing(model, userId);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #2
0
        public IActionResult AddSowing()
        {
            var modelFields      = _fieldService.GetAllFieldForList(userId).Fields;
            var fieldsSelectList =
                modelFields.Select(f => new SelectListItem(f.FieldName, Convert.ToString(f.Id))).ToList();

            var typeSowingSelectList = _typeSowingService.GetAllTypeSowingFotSelectList();

            var model = new NewSowingVm()
            {
                Field      = fieldsSelectList,
                TypeSowing = typeSowingSelectList
            };

            return(View(model));
        }
Пример #3
0
        public int AddSowing(NewSowingVm newSowing, string userId)
        {
            var sowing = _mapper.Map <Sowing>(newSowing);

            sowing.UserId          = userId;
            sowing.TypeTreatmentId = 5;
            Sowing   newestSowing     = _sowingRepository.GetNewestSowingDateTimeInField(sowing.FieldId);
            DateTime newestDateSowing = newestSowing.DateTreatment;
            DateTime oldDateSowing    = sowing.DateTreatment;

            int sowingId = _sowingRepository.AddSowing(sowing);

            if (newestDateSowing < oldDateSowing)
            {
                _fieldRepository.ChangeCultivatedPlant(sowing.FieldId, sowing.CultivatedPlant, sowing.PlantVariety);
            }
            return(sowingId);
        }