コード例 #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);
        }
コード例 #2
0
ファイル: FieldController.cs プロジェクト: Nelliech/GospoRol
        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));
        }
コード例 #3
0
ファイル: FieldController.cs プロジェクト: Nelliech/GospoRol
        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));
        }
コード例 #4
0
        public void UpdateField(NewFieldVm model)
        {
            var field = _mapper.Map <Field>(model);

            _fieldRepository.UpdateField(field);
        }