Пример #1
0
        public IActionResult Index()
        {
            var currentRoleId = partnerManager.GetCurrentUserRole(this.HttpContext);
            var permission    = partnerActivity.GetPartAct("BgService.Query", currentRoleId);

            if (permission == null || permission.Details == null || permission.Details.Count == 0)
            {
                toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية", new ToastrOptions {
                    Title = ""
                });
                return(Redirect(Request.Headers["Referer"].ToString()));
            }
            var model    = new AppBackgroundServiceQueryDto();
            var sources  = new CommonCodeRepo(db).GetCodesByType("bg_service_source");
            var statuses = new CommonCodeRepo(db).GetCodesByType("bg_service_status");

            model.Sources   = sources;
            model.Statuses  = statuses;
            model.StartDate = DateTime.Today.AddMonths(-1);
            model.EndDate   = DateTime.Today;
            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> Index(AppBackgroundServiceQueryDto model)
        {
            var currentRoleId  = partnerManager.GetCurrentUserRole(this.HttpContext);
            var currentId      = partnerManager.GetCurrentUserId(this.HttpContext);
            var currentAccount = partnerManager.GetCurrentUserAccount(this.HttpContext);
            var permission     = partnerActivity.GetPartAct("BgService.Query", currentRoleId);

            if (permission == null || permission.Details == null || permission.Details.Count == 0)
            {
                toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية", new ToastrOptions {
                    Title = ""
                });
                return(Redirect(Request.Headers["Referer"].ToString()));
            }


            var results = await new AppBackgroundServiceRepo(db).GetBackgroundServicesAsync(new AppBackgroundServiceRepo.BackgroundServiceListParam
            {
                Id           = model.Id,
                PartnerId    = model.PartnerId,
                CreatedById  = model.CreatedById,
                IncludeDates = model.IncludeDates,
                StartDate    = model.StartDate,
                EndDate      = model.EndDate,
                Source       = model.Source,
                Status       = model.Status,
                Name         = model.Name
            }, permission, currentId, currentAccount);

            model.Results = results;
            var sources  = new CommonCodeRepo(db).GetCodesByType("bg_service_source");
            var statuses = new CommonCodeRepo(db).GetCodesByType("bg_service_status");

            model.Sources  = sources;
            model.Statuses = statuses;
            return(View(model));
        }