public async Task <ReportListDto> GetFirstOrDefaultAsync <TOrderKey>(Expression <Func <Core.CustomDomain.Report.Report, bool> > predicate, Func <Core.CustomDomain.Report.Report, TOrderKey> orderPredicate, bool isAsc)
        {
            var entityTask = await _reportRepository.GetAllListAsync(predicate);

            Core.CustomDomain.Report.Report entity = isAsc? entityTask.OrderBy(orderPredicate).FirstOrDefault(): entityTask.OrderByDescending(orderPredicate).FirstOrDefault();
            ReportListDto infoDto = entity.MapTo <ReportListDto>();

            return(infoDto);
        }
        public ActionResult Detail(int?id)
        {
            ReportListDto info = new ReportListDto();

            if (id != null)
            {
                info = _reportAppService.GetReportByIdAsync(new EntityDto <int>(id.Value)).Result;
            }


            var userMenu = GetUserMenu(PageNames.Reports).Result;

            ViewBag.UserMenu = userMenu;

            return(View(info));
        }
Beispiel #3
0
        /// <summary>
        /// get report history
        /// </summary>
        /// <param name="reportID"></param>
        /// <returns></returns>
        public IEnumerable <ReportListDto> GetReportListByReportID(string reportID)
        {
            List <ReportListDto> reportLists = new List <ReportListDto>();
            var query = (from r in _dbContext.Set <ReportList>()
                         join u in _dbContext.Set <User>() on r.Creater equals u.UniqueID
                         into ru
                         from ru1 in ru.DefaultIfEmpty()
                         join u2 in _dbContext.Set <User>() on r.Mender equals u2.UniqueID
                         into ru2
                         from ru3 in ru2.DefaultIfEmpty()
                         where r.ReportID == reportID
                         select new
            {
                UniqueID = r.UniqueID,
                WYS = r.WYS,
                WYG = r.WYG,
                IsPositive = r.IsPositive,
                Creater = ru1.LocalName,
                Mender = ru3.LocalName,
                OperationTime = r.OperationTime,
                Status = r.Status
            }).Distinct().OrderByDescending(c => c.OperationTime).ToList();

            foreach (var r in query)
            {
                ReportListDto reportListDto = new ReportListDto
                {
                    UniqueID      = r.UniqueID,
                    WYSText       = ReportMapper.GetStrFromRTF(ReportMapper.GetStringFromBytes(r.WYS)),
                    WYGText       = ReportMapper.GetStrFromRTF(ReportMapper.GetStringFromBytes(r.WYG)),
                    IsPositive    = r.IsPositive,
                    Creater       = r.Creater,
                    Mender        = r.Mender,
                    Status        = r.Status,
                    OperationTime = r.OperationTime
                };
                reportLists.Add(reportListDto);
            }

            return(reportLists);
        }