Beispiel #1
0
 private void PrepareFDPCreate()
 {
     ViewBag.SelectedRegionId = new SelectList(_adminUnitService.GetRegions().Select(p => new{ Id = p.AdminUnitID, p.Name }), "Id", "Name");
     ViewBag.SelectedWoredaId = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
     ViewBag.FDPID            = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
     ViewBag.SelectedZoneId   = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
 }
Beispiel #2
0
        public ActionResult AdminUnits(int?id)
        {
            if (id == null)
            {
                return(new EmptyResult());
            }
            ViewBag.Regions = _adminUnitService.GetRegions();
            var type = _adminUnitService.GetAdminUnitType(id.Value);

            ViewBag.Title          = type.Name + "s";
            ViewBag.SelectedTypeId = id;
            var list = type.AdminUnits.OrderBy(a => a.Name);

            //.Select(s => new Models.AdminUnitItem()
            //{ Id = s.AdminUnitID, Name = s.Name});
            switch (id)
            {
            case 3:
                list = type.AdminUnits.OrderBy(a => a.AdminUnit2.Name).ThenBy(a => a.Name);
                break;

            case 4:
                list = type.AdminUnits.OrderBy(a => a.AdminUnit2.AdminUnit2.Name).ThenBy(a => a.AdminUnit2.Name).ThenBy(a => a.Name);
                break;
            }
            var viewName = "Lists/AdminUnits." + id + "";

            return(PartialView(viewName, list));
        }
Beispiel #3
0
        public ActionResult Compare()
        {
            var hrds  = _hrdService.Get(null, null, "Season");
            var hrds1 =
                (from item in hrds
                 select new { item.HRDID, Name = string.Format("{0}-{1}", item.Season.Name, item.Year) }).ToList();

            ViewBag.firstHrd  = new SelectList(hrds1, "HRDID", "Name");
            ViewBag.secondHrd = new SelectList(hrds1, "HRDID", "Name");
            ViewBag.regionId  = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");

            return(View());
        }
Beispiel #4
0
        //
        // GET: /Procurement/Duplicated/

        public ActionResult Index(int id = 0, int woredaId = 0, int transporterId = 0, int zoneId = 0, int transReqId = 0)
        {
            ViewBag.Month = new SelectList(RequestHelper.GetMonthList(), "Id", "Name");
            ViewBag.TransportOrdrStatus = id;
            ViewBag.TransportOrderTitle = id == 0
                                              ? "Draft"
                                              : _workflowStatusService.GetStatusName(WORKFLOW.TRANSPORT_ORDER, id);
            var allTransporters = _transportOrderService.GetTransporter();

            ViewBag.TransporterID = transporterId == 0 ? new SelectList(allTransporters, "TransporterID", "Name", 0) : new SelectList(allTransporters, "TransporterID", "Name", transporterId);
            ViewBag.Zones         = zoneId == 0 ? new SelectList(_transportOrderService.GetZone(transReqId), "ZoneId", "ZoneName") : new SelectList(_transportOrderService.GetZone(transReqId), "ZoneId", "ZoneName", zoneId);

            ViewBag.RegionID = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
            var viewModel = GetRequisitionsWithoutTransporter(woredaId, transReqId);

            ViewBag.TransReq = transReqId == 0 ? new SelectList(_transReqWithoutTransporterService.Get(t => t.IsAssigned == false).Select(u => u.TransportRequisitionDetail != null ? new
            {
                TransReqID = u.TransportRequisitionDetail.TransportRequisition.TransportRequisitionID,
                TransReqNo = u.TransportRequisitionDetail.TransportRequisition.TransportRequisitionNo
            } : null).Distinct(), "TransReqID", "TransReqNo")
                               : new SelectList(_transReqWithoutTransporterService.Get(t => t.IsAssigned == false).Select(u => u.TransportRequisitionDetail != null ? new
            {
                TransReqID = u.TransportRequisitionDetail.TransportRequisition.TransportRequisitionID,
                TransReqNo = u.TransportRequisitionDetail.TransportRequisition.TransportRequisitionNo
            } : null).Distinct(), "TransReqID", "TransReqNo", transReqId);



            return(View(viewModel));
        }
Beispiel #5
0
        public void init()
        {
            var caseteams = new List <CaseTeam>
            {
                new CaseTeam()
                {
                    ID = 1, CaseTeamName = "EarlyWarning"
                },
                new CaseTeam()
                {
                    ID = 2, CaseTeamName = "PSNP/FSCD"
                },
                new CaseTeam()
                {
                    ID = 3, CaseTeamName = "Logistics"
                },
                new CaseTeam()
                {
                    ID = 4, CaseTeamName = "Procurement"
                },
                new CaseTeam()
                {
                    ID = 5, CaseTeamName = "Finance"
                }
            };
            var userTypes = new SelectList(new[]
            {
                new SelectListItem {
                    Text = "Regional", Value = "1"
                },
                new SelectListItem {
                    Text = "Hub", Value = "2"
                },
                new SelectListItem {
                    Text = "Case team", Value = "3"
                },
                new SelectListItem {
                    Text = "Administrator", Value = "4"
                }
            }, "Text", "Value");

            ViewBag.userTypes = userTypes;
            ViewBag.CaseTeams = caseteams;
            ViewBag.hubs      = _hubService.GetAllHub().ToList();
            ViewBag.regions   = _adminUnitService.GetRegions();
            ViewBag.Programs  = _programService.GetAllProgram().Take(2);
        }
Beispiel #6
0
        //
        // GET: /FDP/

        public virtual ViewResult Index()

        {
            ViewBag.Regions = _adminUnitService.GetRegions();
            var fdps = _FDPService.GetAllFDP();

            return(View(fdps));
        }
Beispiel #7
0
        //
        // GET: /FDP/

        public virtual ViewResult Index()

        {
            ViewBag.Regions = _adminUnitService.GetRegions();
            var fdps          = _FDPService.GetAllFDP();
            var fdpsViewModel = FDPViewModelBinder.FDPListViewModelBinder(fdps);

            return(View(fdpsViewModel));
        }
Beispiel #8
0
        public ActionResult Create(int id = 0)
        {
            ViewBag.RegionID = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
            var datePref = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference;
            var bid      = new CreateBidViewModel();

            bid.StartDate   = DateTime.Now;
            bid.EndDate     = DateTime.Now.AddDays(10);
            bid.OpeningDate = DateTime.Now.AddDays(11);
            var regions = _adminUnitService.FindBy(t => t.AdminUnitTypeID == 2);

            ViewBag.StatusID  = new SelectList(_statusService.GetAllStatus(), "StatusID", "Name", bid.StatusID = 1);
            bid.BidNumber     = _bidService.AutogenerateBidNo();
            ViewBag.BidPlanID = id;

            ViewBag.TransportBidPlanID = new SelectList(_transportBidPlanService.GetAllTransportBidPlan(), "TransportBidPlanID", "ShortName", id);
            return(View(bid));
        }
Beispiel #9
0
        public JsonResult GetRegions()
        {
            var regions = _adminUnitService.GetRegions().Select(r => new
            {
                name = r.Name,
                id   = r.AdminUnitID
            });

            return(Json(regions, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        //
        // GET: /FDP/

        public ActionResult Index()
        {
            ViewBag.RegionCollection = _adminUnitService.GetRegions();
            //ViewData["Zones"] = _adminUnitService.GetZones();
            //ViewData["Regions"] = _adminUnitService.GetAllRegions();
            if (TempData["CustomError"] != null)
            {
                ModelState.AddModelError("Errors", TempData["CustomError"].ToString());
            }
            return(View());
        }
Beispiel #11
0
        public ViewResult Index(int id = 0, int woredaId = 0)
        {
            ViewBag.Month = new SelectList(RequestHelper.GetMonthList(), "Id", "Name");
            ViewBag.TransportOrdrStatus = id;
            ViewBag.TransportOrderTitle = id == 0
                                              ? "Draft"
                                              : _workflowStatusService.GetStatusName(WORKFLOW.TRANSPORT_ORDER, id);
            var allTransporters = _transportOrderService.GetTransporter();

            ViewBag.TransporterID = new SelectList(allTransporters, "TransporterID", "Name", 0);
            ViewBag.Zones         = new SelectList(_transportOrderService.GetZone(), "ZoneId", "ZoneName");
            ViewBag.RegionID      = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
            var viewModel = GetRequisitionsWithoutTransporter(woredaId);



            //viewModel.Transporters = allTransporters;
            if (TempData["CustomError"] != null)
            {
                ModelState.AddModelError("Errors", TempData["CustomError"].ToString());
            }

            else if (TempData["CustomError2"] != null)
            {
                ModelState.AddModelError("Success", TempData["CustomError2"].ToString());
            }
            ViewBag.ProgramID = new SelectList(_transportOrderService.GetPrograms(), "ProgramID", "Name");
            var transportOrderStatus = new List <RequestStatus>
            {
                new RequestStatus()
                {
                    StatusID = 1, StatusName = "Draft"
                },
                new RequestStatus()
                {
                    StatusID = 2, StatusName = "Approved"
                },
                new RequestStatus()
                {
                    StatusID = 3, StatusName = "Signed"
                },
                new RequestStatus()
                {
                    StatusID = 4, StatusName = "Closed"
                }
            };

            ViewBag.StatusID = new SelectList(transportOrderStatus, "StatusID", "StatusName");
            return(View(viewModel));
        }
        public ActionResult DispatchCommodity()
        {
            try
            {
                ViewBag.SelectHubID     = new SelectList(_stockStatusService.GetHubs(), "HubID", "Name");
                ViewBag.SelectProgramID = new SelectList(_stockStatusService.GetPrograms(), "ProgramID", "Name");
                ViewBag.SelectRegionID  = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #13
0
        private void PrepareFDPForEdit(int?fdpid)
        {
            AdminUnitModel unitModel = new AdminUnitModel();
            FDP            fdp;

            if (fdpid != null)
            {
                fdp = _fdpService.FindById(fdpid.Value);
            }
            else
            {
                fdp = null;
            }
            if (fdp != null)
            {
                unitModel.SelectedWoredaId = fdp.AdminUnitID;
                if (fdp.AdminUnit.ParentID != null)
                {
                    unitModel.SelectedZoneId = fdp.AdminUnit.ParentID.Value;
                }

                unitModel.SelectedRegionId = _adminUnitService.GetRegionByZoneId(unitModel.SelectedZoneId);
                ViewBag.Regions            =
                    new SelectList(
                        _adminUnitService.GetRegions().Select(p => new { Id = p.AdminUnitID, Name = p.Name }).OrderBy(
                            o => o.Name), "Id", "Name", unitModel.SelectedRegionId);
                ViewBag.Zones =
                    new SelectList(this.GetChildren(unitModel.SelectedRegionId).OrderBy(o => o.Name), "Id", "Name",
                                   unitModel.SelectedZoneId);
                ViewBag.Woredas =
                    new SelectList(this.GetChildren(unitModel.SelectedZoneId).OrderBy(o => o.Name), "Id", "Name",
                                   unitModel.SelectedWoredaId);
                ViewBag.FDPS = new SelectList(this.GetFdps(unitModel.SelectedWoredaId).OrderBy(o => o.Name), "Id",
                                              "Name", fdp.FDPID);
            }
            else
            {
                ViewBag.SelectedRegionId = new SelectList(unitModel.Regions, "Id", "Name");
                ViewBag.SelectedWoredaId = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
                ViewBag.FDPID            = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
                ViewBag.SelectedZoneId   = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
            }
        }
Beispiel #14
0
        public JsonResult GetAdminUnits()
        {
            var r = (from region in _adminUnitService.GetRegions()
                     select new
            {
                RegionID = region.AdminUnitID,
                RegionName = region.Name,
                Zones = from zone in _adminUnitService.GetZones(region.AdminUnitID)
                        select new
                {
                    ZoneID = zone.AdminUnitID,
                    ZoneName = zone.Name,
                    Woredas = from woreda in _adminUnitService.GetWoreda(zone.AdminUnitID)
                              select new
                    {
                        WoredaID = woreda.AdminUnitID,
                        WoredaName = woreda.Name
                    }
                }
            }
                     );

            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #15
0
 //
 // GET: /Logistics/BeneficiaryAllocation/
 public ActionResult Index()
 {
     ViewBag.RegionID      = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
     ViewBag.RequisitionID = new SelectList(_reliefRequisitionService.Get(t => t.Status == 4).ToList(), "RequisitionID", "RequisitionNo");
     return(View());
 }
Beispiel #16
0
        //
        // 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));
            }
        }