Ejemplo n.º 1
0
        public static async Task <ResponseBase <ReportConfigAddEdit> > EditReport(TeamHttpContext teamHttpContext, int reportId)
        {
            List <ReportConfig> objReportConfig = new List <ReportConfig>();

            using (TeamDbContext dbContext = new TeamDbContext())
            {
                objReportConfig = dbContext.ReportConfigs.Where(x => x.Id == reportId).ToList();
            }

            if (objReportConfig.Count != 0)
            {
                foreach (var item in objReportConfig)
                {
                    ReportConfigAddEdit objReportConfigAddEdit = new ReportConfigAddEdit
                    {
                        ReportId               = item.Id,
                        ReportName             = item.ReportName,
                        ReportConnectionString = item.ReportConnectionString,
                        ReportQuery            = item.ReportQuery,
                        ReportEmail            = item.ReportEmail,
                        ReportFormat           = item.ReportFileFormat,
                        IsActive               = !(item.Deleted),
                        ReportDeliveryMode     = item.ReportDeliveryOption,
                        ReportSMSPhoneNumber   = item.ReportSMSPhNo,
                        ReportDefaultSMSMSG    = item.ReportDefaultSMSMsg,
                        ReportSchedulerName    = item.ReportSchedulerName
                    };

                    return(GetTypedResponse(teamHttpContext, objReportConfigAddEdit));
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        internal static async Task <ResponseBase> editReport(TeamHttpContext httpContext, ReportConfigAddEdit report)
        {
            try
            {
                List <ReportConfig> objReportConfig = new List <ReportConfig>();
                using (TeamDbContext dbContext = new TeamDbContext())
                {
                    if (dbContext.ReportConfigs.AsNoTracking().FirstOrDefault(e => e.Id == report.ReportId) != null)
                    {
                        objReportConfig = dbContext.ReportConfigs.Where(x => x.Id == report.ReportId).ToList();
                    }
                }

                if (objReportConfig.Count != 0)
                {
                    EditReport(new ReportConfig
                    {
                        Id = report.ReportId,
                        ReportReqUserId = httpContext.ContextUserId,
                        //ReportReqUserId = "Admin",
                        ReportName             = report.ReportName,
                        ReportConnectionString = report.ReportConnectionString,
                        ReportQuery            = report.ReportQuery,
                        ReportEmail            = report.ReportEmail,
                        ReportFileFormat       = report.ReportFormat,
                        CreatedBy  = objReportConfig[0].CreatedBy,
                        CreatedOn  = objReportConfig[0].CreatedOn,
                        ModifiedBy = httpContext.ContextUserId,
                        //ModifiedBy = "Admin",
                        ModifiedOn           = DateTime.Now,
                        ReportModifiedOn     = DateTime.Now,
                        Deleted              = !(report.IsActive),
                        ReportDeliveryOption = report.ReportDeliveryMode,
                        ReportSMSPhNo        = report.ReportSMSPhoneNumber,
                        ReportDefaultSMSMsg  = report.ReportDefaultSMSMSG,
                        ReportSchedulerName  = report.ReportSchedulerName
                    });
                    return(GetResponse(httpContext, HttpStatusCode.OK, "Available"));
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(GetResponse(httpContext, HttpStatusCode.BadRequest, ex.Message.ToString()));
            }
        }
Ejemplo n.º 3
0
 internal static async Task <ResponseBase> addReport(TeamHttpContext httpContext, ReportConfigAddEdit report)
 {
     try
     {
         AddReport(new ReportConfig
         {
             ReportReqUserId = httpContext.ContextUserId,
             //ReportReqUserId = "Admin",
             ReportName             = report.ReportName,
             ReportConnectionString = report.ReportConnectionString,
             ReportQuery            = report.ReportQuery,
             ReportEmail            = report.ReportEmail,
             ReportFileFormat       = report.ReportFormat,
             CreatedBy = httpContext.ContextUserId,
             //CreatedBy = "Admin",
             CreatedOn            = DateTime.Now,
             Deleted              = !(report.IsActive),
             ReportDeliveryOption = report.ReportDeliveryMode,
             ReportSMSPhNo        = report.ReportSMSPhoneNumber,
             ReportDefaultSMSMsg  = report.ReportDefaultSMSMSG,
             ReportSchedulerName  = report.ReportSchedulerName
         });
         return(GetResponse(httpContext, HttpStatusCode.OK, "Available"));
     }
     catch (Exception ex)
     {
         return(GetResponse(httpContext, HttpStatusCode.BadRequest, ex.Message.ToString()));
     }
 }
Ejemplo n.º 4
0
        public static async Task <ResponseBase> AddEditReport(TeamHttpContext teamHttpContext, ReportConfigAddEdit report)
        {
            if (teamHttpContext == null)
            {
                throw new ArgumentNullException(nameof(teamHttpContext));
            }
            if (report.ReportId == -1)
            {
                ResponseBase response = await addReport(teamHttpContext, report).ConfigureAwait(false);

                if (response.Code == HttpStatusCode.OK)
                {
                    return(GetResponse(teamHttpContext));
                }
            }
            else
            {
                ResponseBase response = await editReport(teamHttpContext, report).ConfigureAwait(false);

                if (response.Code == HttpStatusCode.OK)
                {
                    return(GetResponse(teamHttpContext));
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
 public async Task <ResponseBase> AddEditReport([FromBody] ReportConfigAddEdit report)
 {
     return(await ReportService.AddEditReport(new TeamHttpContext(HttpContext), report).ConfigureAwait(false));
 }