public Boolean CreateAllocatedPlot(CreateAllocatedPlotInput input) { //get current active financial year; var current = _financialYearRepository.FirstOrDefault(c => c.IsActive == true); if (current != null) { var plot = new AllocatedPlot { DealerId = input.DealerId, FinancialYearId = current.Id, PlotId = input.PlotId, }; if (_allocatedPlotRepository.InsertAndGetId(plot) > 0) { return(true); } else { return(false); } } else { throw new UserFriendlyException("No Active Financial Year"); } }
public ActionResult Create(int DealerId, int CompartmentId, int[] PlotId) { try { // TODO: Add insert logic here if (DealerId > 0 && PlotId.Length > 0) { var plot = new CreateAllocatedPlotInput(); foreach (var Id in PlotId) { plot.DealerId = DealerId; plot.PlotId = Id; if (_allocatedPlotAppService.CreateAllocatedPlot(plot)) { _plotAppService.UpdatePlotAllocation(_plotAppService.GetPlot(Id)); } } return(RedirectToAction("Index", new { Id = DealerId })); } else { ModelState.AddModelError("", "Make sure Dealer and Plot are selected"); return(RedirectToAction("Tallied", "Plots", new { Id = CompartmentId })); } } catch { ModelState.AddModelError("", "Make sure Dealer and Plot are selected"); return(RedirectToAction("Tallied", "Plots", new { Id = CompartmentId })); } }