Example #1
0
        public IActionResult EditLand(NewLandVm model, decimal oldAcreage, decimal oldAcreageFree)
        {
            if (ModelState.IsValid)
            {
                _landService.UpdateLand(model, oldAcreage, oldAcreageFree);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Example #2
0
        public IActionResult AddLand(NewLandVm model)
        {
            if (ModelState.IsValid)
            {
                _landService.AddLand(model, userId);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Example #3
0
        public void AddLand(NewLandVm newLand, string userId)
        {
            var land = _mapper.Map <Land>(newLand);

            land.AcreageFree     = land.Acreage;
            land.AcreageOccupied = 0;
            land.UserId          = userId;

            _genericRepository.Add <Land>(land);
        }
Example #4
0
        public void UpdateLand(NewLandVm model, decimal oldAcreage, decimal oldAcreageFree)
        {
            var newLand = _mapper.Map <Land>(model);

            if (newLand.Acreage > oldAcreage)
            {
                newLand.AcreageFree = newLand.AcreageFree + (newLand.Acreage - oldAcreage);
            }
            else
            {
                newLand.AcreageFree = newLand.AcreageFree - (oldAcreage - newLand.Acreage);
            }
            _landRepository.UpdateLand(newLand);
        }