Exemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(string idForm)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var mtdFormList = await ApprovalHandler.GetWaitStoreIds(_context, user, idForm);

            int pending = mtdFormList.Count();

            string    searchText = "";
            bool      whiteList  = false;
            MtdFilter filter     = await _context.MtdFilter.FirstOrDefaultAsync(x => x.IdUser == user.Id && x.MtdForm == idForm);

            if (filter != null)
            {
                searchText = filter.SearchText;
                whiteList  = filter.WaitList == 0 ? false : true;
            }

            HeaderModelView headerModelView = new HeaderModelView
            {
                IdForm         = idForm,
                SearchText     = searchText,
                WaitList       = whiteList,
                Pending        = pending,
                IsApprovalForm = await ApprovalHandler.IsApprovalFormAsync(_context, idForm)
            };

            return(View("Default", headerModelView));
        }
Exemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync(string idForm)
        {
            var user = await _userHandler.GetUserAsync(HttpContext.User);

            List <string> partIds = await _userHandler.GetAllowPartsForView(user, idForm);

            FilterHandler handlerFilter = new FilterHandler(_context, idForm, user, _userHandler);
            Incomer       incomer       = await handlerFilter.GetIncomerDataAsync();

            TypeQuery typeQuery = await handlerFilter.GetTypeQueryAsync();

            OutFlow outFlow = await handlerFilter.GetStackFlowAsync(incomer, typeQuery);

            IList <MtdStore> mtdStore = outFlow.MtdStores;

            decimal count = (decimal)outFlow.Count / incomer.PageSize;

            pageCount = Convert.ToInt32(Math.Round(count, MidpointRounding.AwayFromZero));
            pageCount = pageCount == 0 ? 1 : pageCount;

            IList <string> storeIds = mtdStore.Select(s => s.Id).ToList();
            IList <string> fieldIds = fieldIds = incomer.FieldForColumn.Select(x => x.Id).ToList();

            IList <string> allowFiieldIds = await _context.MtdFormPartField.Where(x => partIds.Contains(x.MtdFormPart)).Select(x => x.Id).ToListAsync();

            fieldIds = allowFiieldIds.Where(x => fieldIds.Contains(x)).ToList();

            StackHandler          handlerStack  = new StackHandler(_context);
            IList <MtdStoreStack> mtdStoreStack = await handlerStack.GetStackAsync(storeIds, fieldIds);

            IList <MtdStoreApproval> mtdStoreApprovals = await _context.MtdStoreApproval.Where(x => storeIds.Contains(x.Id)).ToListAsync();

            List <ApprovalStore> approvalStores = await ApprovalHandler.GetStoreStatusAsync(_context, storeIds, user);

            bool isApprovalForm = await ApprovalHandler.IsApprovalFormAsync(_context, idForm);

            RowsModelView rowsModel = new RowsModelView
            {
                IdForm            = idForm,
                SearchNumber      = incomer.SearchNumber,
                PageCount         = pageCount,
                MtdFormPartFields = incomer.FieldForColumn.Where(x => fieldIds.Contains(x.Id)).ToList(),
                MtdStores         = mtdStore,
                MtdStoreStack     = mtdStoreStack,
                WaitList          = incomer.WaitList == 1 ? true : false,
                ShowDate          = await handlerFilter.IsShowDate(),
                ShowNumber        = await handlerFilter.IsShowNumber(),
                ApprovalStores    = approvalStores,
                IsAppromalForm    = isApprovalForm
            };

            return(View("Default", rowsModel));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MtdStore = await _context.MtdStore.FirstOrDefaultAsync(m => m.Id == id);

            if (MtdStore == null)
            {
                return(NotFound());
            }

            var user = await _userHandler.GetUserAsync(HttpContext.User);

            bool isViewer = await _userHandler.IsViewer(user, MtdStore.MtdForm, MtdStore.Id);

            IsEditor = await _userHandler.IsEditor(user, MtdStore.MtdForm, MtdStore.Id);

            IsInstallerOwner = await _userHandler.IsInstallerOwner(user, MtdStore.MtdForm, MtdStore.Id);

            if (!isViewer)
            {
                return(Forbid());
            }


            MtdForm = await _context.MtdForm.Include(m => m.InverseParentNavigation).FirstOrDefaultAsync(x => x.Id == MtdStore.MtdForm);

            MtdLogDocument edited = await _context.MtdLogDocument.Where(x => x.MtdStore == MtdStore.Id).OrderByDescending(x => x.TimeCh).FirstOrDefaultAsync();

            MtdLogDocument created = await _context.MtdLogDocument.Where(x => x.MtdStore == MtdStore.Id).OrderBy(x => x.TimeCh).FirstOrDefaultAsync();

            StoreOwner = await _context.MtdStoreOwner.Where(x => x.Id == MtdStore.Id).FirstOrDefaultAsync();

            ChangesHistory = new ChangesHistory
            {
                CreateByTime = MtdStore.Timecr.ToString()
            };

            if (edited != null)
            {
                ChangesHistory.LastEditedUser = edited.UserName;
                ChangesHistory.LastEditedTime = edited.TimeCh.ToString();
            }

            if (created != null)
            {
                if (MtdStore.Timecr.Date == created.TimeCh.Date)
                {
                    ChangesHistory.CreateByUser = created.UserName;
                }
            }

            List <WebAppUser> webAppUsers = await _userHandler.GetUsersInGroupsAsync(user);

            ViewData["UsersList"] = new SelectList(webAppUsers, "Id", "Title");

            ApprovalHandler approvalHandler = new ApprovalHandler(_context, MtdStore.Id);

            IsApprover = await approvalHandler.IsApproverAsync(user);

            IsFirstStage = await approvalHandler.IsFirstStageAsync();

            IList <MtdApprovalStage> stages = await approvalHandler.GetStagesDownAsync();

            ViewData["Stages"] = new SelectList(stages.OrderByDescending(x => x.Stage), "Id", "Name");

            List <string> partIds = await approvalHandler.GetWilBeBlockedPartsIds();

            BlockParts = new List <MtdFormPart>();
            if (partIds.Count > 0)
            {
                BlockParts = await _context.MtdFormPart.Where(x => partIds.Contains(x.Id)).OrderBy(x => x.Sequence).ToListAsync();
            }
            IsFormApproval = await approvalHandler.IsApprovalFormAsync();

            if (IsFormApproval)
            {
                ApprovalStatus = await approvalHandler.GetStatusAsync(user);
            }


            return(Page());
        }