public IActionResult Reports(int id)
        {
            var        psychologist = _unitOfWork.Psychologists.Get(id);
            ReportsDTO reportsDTO   = new ReportsDTO();

            reportsDTO.Psychologist = psychologist;

            var reportsFromDB           = _unitOfWork.Reports.GetAll().Where(r => r.PsychologistId == id).OrderByDescending(r => r.Id).ToList();
            List <ReportDTO> reportDTOs = new List <ReportDTO>();

            /*for (int i = 0; i < reportsFromDB.Count; i++)
             * {
             *  if(reportsFromDB[i].IsAnonymous)
             *  {
             *      reportsFromDB[i].AuthorizedUser.FirstName = "Suka" + i;
             *      reportsFromDB[i].AuthorizedUser.LastName = "";
             *  }
             * }
             * reportsDTO.Reports = reportsFromDB;*/
            foreach (var elem in reportsFromDB)
            {
                reportDTOs.Add(new ReportDTO
                {
                    Message     = elem.Message,
                    IsAnonymous = elem.IsAnonymous,
                    FirstName   = elem.IsAnonymous ? "Anonymous" : elem.AuthorizedUser.FirstName,
                    LastName    = elem.IsAnonymous ? "" : elem.AuthorizedUser.LastName
                });
            }

            reportsDTO.Reports = reportDTOs;

            return(PartialView(reportsDTO));
        }
Пример #2
0
        //To get workspaces
        public ReportsDTO GetReportsAndOwner(string workspaceid)
        {
            using (var context = new BIPortalEntities())
            {
                var result = new ReportsDTO();
                result.Users = context.UserMasters.Where(x => x.Active == true).Select(x => new UsersDTO()
                {
                    UserID = x.UserID, UserName = x.FirstName + " " + x.LastName
                }).ToList();

                result.Reports = context.WorkspaceReportsMasters.Where(x => x.WorkspaceID == workspaceid && x.ReportID != null).Select(x => new ReportsDTO()
                {
                    ReportId = x.ReportID, ReportName = x.ReportName
                }).ToList();

                return(result);
            }
        }
Пример #3
0
        //To get workspaces
        public ReportsDTO GetReportsAndEmbedUrl(int?requestId)
        {
            using (var context = new BIPortalEntities())
            {
                var result = new ReportsDTO();
                //result.Users = context.UserMasters.Where(x => x.Active == true).Select(x => new UsersDTO() { UserID = x.UserID, UserName = x.FirstName + " " + x.LastName }).ToList();

                //result.Reports = context.WorkspaceReportsMasters.Where(x => x.WorkspaceID == workspaceid && x.ReportID != null).Select(x => new ReportsDTO() { ReportId = x.ReportID, ReportName = x.ReportName,ReportEmbedUrl=x.ReportEmbedUrl }).ToList();
                //result.Reports = context.WorkFlowDetails.Where(x => x.RequestID == requestId).Select(x => new ReportsDTO() { ReportId = x.ReportID, ReportName = x.ReportName }).ToList();

                result.Reports = (from d in context.WorkFlowDetails
                                  join e in context.WorkspaceReportsMasters on d.ReportID equals e.ReportID
                                  where d.RequestID == requestId
                                  select new { d.ReportID, d.ReportName, e.ReportEmbedUrl })
                                 .Select(x => new ReportsDTO()
                {
                    ReportId = x.ReportID, ReportName = x.ReportName, ReportEmbedUrl = x.ReportEmbedUrl
                }).ToList();

                return(result);
            }
        }
        public ReportsDTO GetReports()
        {
            const string commandText = "EXEC GetReports";

            using (SqlConnection dbConnection = new SqlConnection(connectionString))
            {
                dbConnection.Open();

                using (SqlCommand dbCommand = dbConnection.CreateCommand())
                {
                    dbCommand.CommandText = commandText;

                    using (SqlDataReader reader = dbCommand.ExecuteReader())
                    {
                        var nullableIntConverter     = new NullableIntConverterFromObject();
                        var nullableDecimalConverter = new NullableDecimalConverterFromObject();

                        ReportsDTO reportsDTO = new ReportsDTO();

                        var vendaPorPeriodoList = new List <VendaPorPeriodoDTO>();
                        while (reader.Read())
                        {
                            var vendaPorPeriodo = new VendaPorPeriodoDTO();

                            vendaPorPeriodo.Ano          = nullableIntConverter.Converter(reader[CAMPO_ANO]);
                            vendaPorPeriodo.Mes          = nullableIntConverter.Converter(reader[CAMPO_MES]);
                            vendaPorPeriodo.ValorVendido = nullableDecimalConverter.Converter(reader[CAMPO_VALOR_VENDIDO]);

                            vendaPorPeriodoList.Add(vendaPorPeriodo);
                        }

                        reader.NextResult();

                        var vendaPorCategoriaList = new List <VendaPorCategoriaDTO>();
                        while (reader.Read())
                        {
                            var vendaPorCategoria = new VendaPorCategoriaDTO();

                            vendaPorCategoria.Categoria    = Convert.ToString(reader[CAMPO_CATEGORIA]);
                            vendaPorCategoria.ValorVendido = nullableDecimalConverter.Converter(reader[CAMPO_VALOR_VENDIDO]);

                            vendaPorCategoriaList.Add(vendaPorCategoria);
                        }

                        reader.NextResult();

                        var vendaPorProdutoList = new List <VendaPorProdutoDTO>();
                        while (reader.Read())
                        {
                            var vendaPorProduto = new VendaPorProdutoDTO();

                            vendaPorProduto.CodigoProduto = nullableIntConverter.Converter(reader[CAMPO_CODIGO_PRODUTO]);
                            vendaPorProduto.Quantidade    = nullableIntConverter.Converter(reader[CAMPO_QUANTIDADE]);

                            vendaPorProdutoList.Add(vendaPorProduto);
                        }

                        var reports = new ReportsDTO
                        {
                            VendasPorPeriodo   = vendaPorPeriodoList,
                            VendasPorCategoria = vendaPorCategoriaList,
                            VendasPorProduto   = vendaPorProdutoList
                        };

                        return(reports);
                    }
                }
            }
        }
Пример #5
0
    /// <summary>
    /// Populate the reports from server
    /// </summary>
    /// <param name="jsonString">json string response from server</param>
    private void GetReportsFromServer(string jsonString)
    {
        ReportsDTO ReportList = JsonUtility.FromJson <ReportsDTO>(jsonString);

        reports = ReportList.Reports;
    }
Пример #6
0
        public ReportsDTO Get()
        {
            ReportsDTO reportsDTO = reportsService.GetReports();

            return(reportsDTO);
        }