Esempio n. 1
0
        public void AddField(NewFieldVm newField, int landId, string userId)
        {
            var field = _mapper.Map <Field>(newField);

            field.LandId = landId;
            field.UserId = userId;
            _genericRepository.Add <Field>(field);
            _landRepository.ChangeAcreageOccupied(field.Acreage, landId);
        }
Esempio n. 2
0
        public IActionResult AddField(NewFieldVm model, int landId)
        {
            var land = _landService.GetLandById(landId);

            if (land.AcreageFree < model.Acreage)
            {
                return(RedirectToAction("NoFreeAcreage", new { landName = land.PlotNumber }));
            }

            if (ModelState.IsValid)
            {
                _fieldService.AddField(model, landId, userId);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Esempio n. 3
0
        public IActionResult AddField()
        {
            var land = _landService.GetAllLandForList(userId);

            if (land.Count == 0)
            {
                return(RedirectToAction("LandDontExist"));
            }
            //Dropdown list with plot number
            var landSelectList = _landService.GetAllLandForSelectList(userId);
            //Dropdown list with agricultural Class
            var agrClassSelectList = _agriculturalClassService.GetAllAgriculturalClassForSelectList();

            var viewModel = new NewFieldVm()
            {
                Lands = landSelectList,
                AgriculturalClasses = agrClassSelectList
            };

            return(View(viewModel));
        }
Esempio n. 4
0
        public void UpdateField(NewFieldVm model)
        {
            var field = _mapper.Map <Field>(model);

            _fieldRepository.UpdateField(field);
        }