Beispiel #1
0
        public async Task <ActionResult> Index(int?contractID, int?periodID, string requirementStatusID, int?entityTypeID)
        {
            ViewBag.ContractID          = new SelectList(await contractRepository.FindContractsAsync(base.CurrentContractorID), "ContractID", "ContractCode");
            ViewBag.PeriodID            = new SelectList(await periodRepository.FindPeriodsAsync(), "PeriodID", "PeriodID");
            ViewBag.RequirementStatusID = new SelectList(Enum.GetNames(typeof(RequirementStatus)));
            ViewBag.EntityTypeID        = new SelectList(await entityTypeRepository.EntityTypesAsync(), "EntityTypeID", "Description");

            RequirementStatus requirementStatus = !string.IsNullOrEmpty(requirementStatusID) ? (RequirementStatus)Enum.Parse(typeof(RequirementStatus), requirementStatusID) : 0;

            var requirements = await requirementRepository.FindRequirementsByFilterAsync(0, 0, contractID == null? 0 : contractID.Value, periodID == null? 0 : periodID.Value, requirementStatus, entityTypeID == null? 0 : entityTypeID.Value);

            var requirementsViewModel = new RequirementListViewModel(requirements.ToList());

            return(View(requirementsViewModel));
        }
        // GET: CustomerRequirements
        public async Task <ActionResult> Index(int?contractorID, int?contractID, int?periodID)
        {
            //Contractors por Customer
            ViewBag.ContractorID = new SelectList(await contractorRepository.FindContractorsAsync(base.CurrentCustomerID), "ContractorID", "CompanyName");

            //Contracts por Contractor
            ViewBag.ContractID = new SelectList(await contractRepository.FindContractsAsync(base.CurrentContractorID), "ContractID", "ContractCode");

            ViewBag.PeriodID = new SelectList(await periodRepository.FindPeriodsAsync(), "PeriodID", "PeriodID");

            RequirementStatus requirementStatus = 0; // !string.IsNullOrEmpty(string.Empty) ? (RequirementStatus)Enum.Parse(typeof(RequirementStatus), requirementStatusID) : 0;
            var requirements = await requirementRepository.FindRequirementsByFilterAsync(0, contractorID == null? 0 : contractorID.Value, contractID == null? 0 : contractID.Value, periodID == null? 0 : periodID.Value, requirementStatus, 0);

            var requirementsViewModel = new RequirementListViewModel(requirements.ToList());

            return(View(requirementsViewModel));
        }
Beispiel #3
0
        public async Task <ActionResult> Index(int?customerID, int?contractorID, int?periodID, string requirementStatusID, int?entityTypeID)
        {
            var customersByAuditor = await customerAuditorRespository.FindCustomerAuditorsByUserIDAsync(this.CurrentUserID);

            var customerIDFilter = customerID == null?customersByAuditor.FirstOrDefault().CustomerID : customerID;

            var contractors = await contractorRepository.FindContractorsByCustomerIDAsync((int)customerIDFilter);

            var contractorIDFilter = contractors != null && contractorID == null?contractors.FirstOrDefault()?.ContractorID : contractorID;

            ViewBag.PeriodID            = new SelectList(await periodRepository.FindPeriodsAsync(), "PeriodID", "PeriodID");
            ViewBag.RequirementStatusID = new SelectList(Enum.GetNames(typeof(RequirementStatus)));
            ViewBag.EntityTypeID        = new SelectList(await entityTypeRepository.EntityTypesAsync(), "EntityTypeID", "Description");

            RequirementStatus requirementStatus = !string.IsNullOrEmpty(requirementStatusID) ? (RequirementStatus)Enum.Parse(typeof(RequirementStatus), requirementStatusID) : 0;

            //var requirements = await requirementRepository.FindRequirementsByFilterAsync((int)customerIDFilter, (int)contractorIDFilter, 0, periodID == null ? 0 : periodID.Value, requirementStatus, entityTypeID == null ? 0 : entityTypeID.Value);
            var requirements = await requirementRepository.FindRequirementsByFilterAsync((int)customerIDFilter, contractorIDFilter == null? 0 : contractorIDFilter.Value, 0, periodID == null? 0 : periodID.Value, requirementStatus, entityTypeID == null? 0 : entityTypeID.Value);


            var requirementsViewModel = new RequirementListViewModel(requirements.ToList());

            ViewBag.CustomerID   = customerIDFilter;
            ViewBag.ContractorId = contractorIDFilter;

            requirementsViewModel.Customers = customersByAuditor.Select(x => new SelectListItem()
            {
                Value = x.CustomerID.ToString(), Text = x.Customer.FullCompanyName
            });
            requirementsViewModel.Contractors = contractors.Select(x => new SelectListItem()
            {
                Value = x.ContractorID.ToString(), Text = x.FullCompanyName
            });


            return(View(requirementsViewModel));
        }
Beispiel #4
0
        public async Task <IActionResult> GetRequirementList(string badgeIds,
                                                             string challengeIds,
                                                             string scope,
                                                             string search,
                                                             int page      = 1,
                                                             int?thisBadge = null)
        {
            var filter = new BaseFilter(page, 10)
            {
                Search = search
            };

            var badgeList = new List <int>();

            if (thisBadge.HasValue)
            {
                badgeList.Add(thisBadge.Value);
            }
            if (!string.IsNullOrWhiteSpace(badgeIds))
            {
                badgeList.AddRange(badgeIds.Split(',')
                                   .Where(_ => !string.IsNullOrWhiteSpace(_))
                                   .Select(int.Parse)
                                   .ToList());
            }
            if (badgeList.Count > 0)
            {
                filter.BadgeIds = badgeList;
            }

            if (!string.IsNullOrWhiteSpace(challengeIds))
            {
                filter.ChallengeIds = challengeIds.Split(',')
                                      .Where(_ => !string.IsNullOrWhiteSpace(_))
                                      .Select(int.Parse)
                                      .ToList();
            }
            switch (scope)
            {
            case ("System"):
                filter.SystemIds = new List <int> {
                    GetId(ClaimType.SystemId)
                };
                break;

            case ("Branch"):
                filter.BranchIds = new List <int> {
                    GetId(ClaimType.BranchId)
                };
                break;

            case ("Mine"):
                filter.UserIds = new List <int> {
                    GetId(ClaimType.UserId)
                };
                break;

            default:
                break;
            }

            var requirements = await _triggerService.PageRequirementAsync(filter);

            var paginateModel = new PaginateViewModel
            {
                ItemCount    = requirements.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };
            var viewModel = new RequirementListViewModel
            {
                Requirements  = requirements.Data,
                PaginateModel = paginateModel
            };

            foreach (var requirement in requirements.Data)
            {
                if (!string.IsNullOrWhiteSpace(requirement.BadgePath))
                {
                    requirement.BadgePath = _pathResolver.ResolveContentPath(requirement.BadgePath);
                }
            }

            return(PartialView("_RequirementsPartial", viewModel));
        }