public IActionResult EditLand(NewLandVm model, decimal oldAcreage, decimal oldAcreageFree) { if (ModelState.IsValid) { _landService.UpdateLand(model, oldAcreage, oldAcreageFree); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult AddLand(NewLandVm model) { if (ModelState.IsValid) { _landService.AddLand(model, userId); return(RedirectToAction("Index")); } return(View(model)); }
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); }
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); }