Exemple #1
0
        public List <ReportModel> GetReportsListByUser(int projectId, UserModel loggedinUser)
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            try
            {
                using (ProjectDB projectDB = new ProjectDB())
                {
                    var projectMapping = projectDB.GetProjectMappingByUser(projectId, loggedinUser.Pfid);

                    // If no mapping found then user is not assigned the project.
                    if (projectMapping == null)
                    {
                        return(null);
                    }

                    // If user is project admin, then return all reports, else return reports assigned to user.
                    if (projectMapping.IsProjectAdmin == 1)
                    {
                        return(projectDB.GetReportsByProject(projectId).Where(p => p.IsActive == 1).ToList());
                    }

                    return(projectDB.GetReportMappingByUser(projectId, loggedinUser.Pfid));
                }
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
Exemple #2
0
        public ActionResult AssignReportsList(int projectId, int pfid)
        {
            var Result = new object();

            using (ProjectDB projectDB = new ProjectDB())
            {
                List <ReportModel> reportList    = projectDB.GetReportsByProject(projectId).Where(p => p.IsActive == 1).ToList();
                List <ReportModel> reportsMapped = projectDB.GetReportMappingByUser(projectId, pfid);
                Result = new
                {
                    aaData = (from report in reportList
                              select new
                    {
                        Id = report.Id,
                        Name = report.Name,
                        Description = report.Description,
                        ProcedureName = report.ProcedureName,
                        ProjectId = report.ProjectId,
                        ProjectName = report.ProjectName,
                        ConnectionId = report.ConnectionId,
                        ConnectionName = report.ConnectionName,
                        IsAssigned = reportsMapped.FirstOrDefault(rm => rm.Id == report.Id) != null,
                        Action = ""
                    }
                              ).ToArray()
                };
            }
            return(Json(Result, JsonRequestBehavior.AllowGet));
        }