// // GET: /FDP/ public virtual ViewResult Index() { ViewBag.Regions = _adminUnitService.GetRegions(); var fdps = _FDPService.GetAllFDP(); return(View(fdps)); }
// // GET: /FDP/ public virtual ViewResult Index() { ViewBag.Regions = _adminUnitService.GetRegions(); var fdps = _FDPService.GetAllFDP(); var fdpsViewModel = FDPViewModelBinder.FDPListViewModelBinder(fdps); return(View(fdpsViewModel)); }
// // GET: /Dispatch/Create public ActionResult Create(string ginNo, int type) { var commodities = _commodityService.GetAllCommodity(); var transporters = _transporterService.GetAllTransporter(); var units = _unitService.GetAllUnit(); var fdps = _fdpService.GetAllFDP(); var programs = _programService.GetAllProgram(); var regions = _adminUnitService.GetRegions(); var zones = _adminUnitService.GetAllAdminUnit().Where(t => t.AdminUnitTypeID == 2).ToList(); var stores = _storeService.GetAllStore(); ViewBag.Units = _unitService.GetAllUnit(); var dispatch = _dispatchService.GetDispatchByGIN(ginNo); var user = _userProfileService.GetUser(User.Identity.Name); if (dispatch != null) { if (user.DefaultHub != null && user.DefaultHub.HubID == dispatch.HubID) { PrepareEdit(dispatch, user, type); var transaction = _dispatchService.GetDispatchTransaction(dispatch.DispatchID); var dis = DispatchModel.GenerateDispatchModel(dispatch, transaction, commodities, transporters, units, fdps, programs, regions, zones, stores); return(View(dis)); } PrepareCreate(type); var comms = new List <DispatchDetailModel>(); ViewBag.SelectedCommodities = comms; var theViewModel = new DispatchModel(commodities, transporters, units, fdps, programs, regions, zones, stores) { Type = type, DispatchDetails = comms }; ViewBag.Message = "The selected GIN Number doesn't exist on your default warehouse. Try changing your default warehouse."; return(View(theViewModel)); } else { PrepareCreate(type); var comms = new List <DispatchDetailModel>(); ViewBag.SelectedCommodities = comms; var theViewModel = new DispatchModel(commodities, transporters, units, fdps, programs, regions, zones, stores) { Type = type, DispatchDetails = comms }; if (Request["type"] != null && Request["allocationId"] != null) { var allocationId = Guid.Parse(Request["allocationId"]); var allocationTypeId = Convert.ToInt32(Request["type"]); if (allocationTypeId == 1)//to FDP { DispatchAllocation toFDPDispatchAllocation = _dispatchAllocationService.FindById(allocationId); theViewModel.FDPID = toFDPDispatchAllocation.FDPID; PrepareFDPForEdit(toFDPDispatchAllocation.FDPID); theViewModel.RequisitionNo = toFDPDispatchAllocation.RequisitionNo; theViewModel.BidNumber = toFDPDispatchAllocation.BidRefNo; theViewModel.SINumber = toFDPDispatchAllocation.ShippingInstruction.Value; theViewModel.ProjectNumber = toFDPDispatchAllocation.ProjectCode.Value; theViewModel.CommodityTypeID = toFDPDispatchAllocation.Commodity.CommodityTypeID; ViewBag.CommodityTypeID = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name", toFDPDispatchAllocation.Commodity.CommodityTypeID); if (toFDPDispatchAllocation.ProgramID.HasValue) { theViewModel.ProgramID = toFDPDispatchAllocation.ProgramID.Value; ViewBag.ProgramID = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name", theViewModel.ProgramID); } if (toFDPDispatchAllocation.TransporterID.HasValue) { theViewModel.TransporterID = toFDPDispatchAllocation.TransporterID.Value; } ViewBag.TransporterID = new SelectList(_transporterService.GetAllTransporter(), "TransporterID", "Name", theViewModel.TransporterID); if (toFDPDispatchAllocation.Year.HasValue) { theViewModel.Year = toFDPDispatchAllocation.Year.Value; } var years = (from y in _periodService.GetYears() select new { Name = y, Id = y }).ToList(); ViewBag.Year = new SelectList(years, "Id", "Name"); ViewBag.Year = new SelectList(years, "Id", "Name", theViewModel.Year); if (toFDPDispatchAllocation.Month.HasValue) { theViewModel.Month = toFDPDispatchAllocation.Month.Value; } var months = (from y in _periodService.GetMonths(theViewModel.Year) select new { Name = y, Id = y }).ToList(); ViewBag.Month = new SelectList(months, "Id", "Name", theViewModel.Month); if (toFDPDispatchAllocation.Round.HasValue) { theViewModel.Round = toFDPDispatchAllocation.Round.Value; } theViewModel.DispatchAllocationID = toFDPDispatchAllocation.DispatchAllocationID; } else //allocationTypeId == 2 { var otherDispatchAllocation = _otherDispatchAllocationService.FindById(allocationId); theViewModel.ToHubID = otherDispatchAllocation.ToHubID; theViewModel.SINumber = otherDispatchAllocation.ShippingInstruction.Value; theViewModel.ProjectNumber = otherDispatchAllocation.ProjectCode.Value; theViewModel.ProgramID = otherDispatchAllocation.ProgramID; theViewModel.CommodityTypeID = otherDispatchAllocation.Commodity.CommodityTypeID; ViewBag.CommodityTypeID = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name", otherDispatchAllocation.Commodity.CommodityTypeID); ViewBag.ProgramID = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name", theViewModel.ProgramID); theViewModel.OtherDispatchAllocationID = otherDispatchAllocation.OtherDispatchAllocationID; } } return(View(theViewModel)); } }