public async Task <IActionResult> ShowDocuments(int id)
        {
            var activity = await _context.Activities
                           .Include(a => a.Documents)
                           .ThenInclude(d => d.User)
                           .FirstOrDefaultAsync(a => a.Id == id);

            //endast inlämningar från elever
            if (activity.Documents == null)
            {
                return(NotFound());
            }
            var documents = activity.Documents
                            .GroupBy(d => d.UserId)
                            .Select(d => d.First())
                            .ToList();

            var model = new ShowDocuments
            {
                Id        = id,
                Documents = documents
            };

            if (model == null)
            {
                return(NotFound());
            }
            if (Request.IsAjax())
            {
                return(PartialView("ShowDocumentsPartial", model));
            }
            return(View(model));
        }
예제 #2
0
        protected override void FinPeriod_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            base.FinPeriod_RowSelected(sender, e);

            bool anyPeriodSelected = ShowDocuments.GetEnabled();

            ShowUnpostedDocuments.SetEnabled(anyPeriodSelected);

            var row = (FinPeriod)e.Row;

            if (row == null)
            {
                return;
            }

            bool      warnDocsUnposted    = (row.Selected == true && UnpostedDocuments.View.SelectSingleBound(new[] { row }) != null);
            Exception warnDocsUnpostedExc = warnDocsUnposted ? new PXSetPropertyException(Messages.UnpostedDocsExist, PXErrorLevel.RowWarning) : null;

            PeriodList.Cache.RaiseExceptionHandling <FinPeriod.selected>(row, null, warnDocsUnpostedExc);
        }