public ActionResult Add([ModelBinder(typeof(DevExpressEditorsBinder))]  ReportModel reportModel)
        {
            reportModel._UserId = (int)Session["userId"];

            //value di set sesaat sebelum di post ke server : tidak tertampung di DXMVCEditorsValues sengginga tidak terbaca di model
            reportModel._HiddenUid = Request["_HiddenUid"];

            reportService = new ReportService();


            if (ModelState.IsValid)
            {
                if (reportModel._HiddenUid != "")
                {
                    reportModel.Data = System.IO.File.ReadAllBytes(ReportUploadControlHelper.GetFilePath(reportModel._HiddenUid));
                }

                reportService.Add(reportModel);
                reportModel = reportService.GetNewModel();
            }
            else
            {
                string message = GetErrorModel();

                throw new Exception(string.Format("[VALIDATION] {0}", message));
            }


            reportModel._FormMode = Models.FormModeEnum.New;

            return(PartialView(VIEW_FORM_PARTIAL, reportModel));
        }
        public void TestAdd()
        {
            _mockReportRepository.Setup(x => x.Add(It.IsAny <Report>())).Returns(report);
            var    reportService = new ReportService(_mockReportRepository.Object);
            Report reportActual  = reportService.Add(report);

            Assert.AreEqual(reportActual.Content, "vi pham");
        }
Esempio n. 3
0
        public ActionResult Log(ActionOnLogData logData)
        {
            if (User.Identity.IsAuthenticated)
            {
                logData.UserID = User.GetUser().Id;
            }
            logData.Value    = 1;
            logData.DateTime = DateTime.Now;
            var res = _rptSrv.Add(logData);

            return(Json(res));
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Report report = null;

            using (new UnitOfWorkScope())
            {
                ReportService service = new ReportService();

                int reportId = int.Parse(hfReportId.Value);

                if (reportId == 0)
                {
                    report          = new Report();
                    report.IsSystem = false;
                }
                else
                {
                    report = service.Get(reportId);
                }

                report.Name         = tbName.Text;
                report.Description  = tbDescription.Text;
                report.CategoryId   = cpCategory.SelectedValueAsInt();
                report.EntityTypeId = ddlEntityType.SelectedValueAsInt();
                report.DataViewId   = ddlDataView.SelectedValueAsInt();

                if (!Page.IsValid)
                {
                    return;
                }

                if (!report.IsValid)
                {
                    // Controls will render the error messages
                    return;
                }

                RockTransactionScope.WrapTransaction(() =>
                {
                    if (report.Id.Equals(0))
                    {
                        service.Add(report, CurrentPersonId);
                    }

                    service.Save(report, CurrentPersonId);
                });
            }

            var qryParams = new Dictionary <string, string>();

            qryParams["ReportId"] = report.Id.ToString();
            NavigateToPage(this.CurrentPage.Guid, qryParams);
        }
Esempio n. 5
0
        public void AddReportTests()
        {
            var builder = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            applicationDbContext = new ApplicationDbContext(builder.Options, configuration);
            repository           = new Repository <Report>(applicationDbContext);
            reportService        = new ReportService(repository);
            reportService.Add(new Report()
            {
                Id = Guid.Parse("1b7b7549-9338-43dc-a1a1-de9b9a40bf60")
            });
            Assert.Equal(1, applicationDbContext.Reports.Count());
        }
Esempio n. 6
0
        public void RemoveReportTests()
        {
            var builder = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            applicationDbContext = new ApplicationDbContext(builder.Options, configuration);
            repository           = new Repository <Report>(applicationDbContext);
            reportService        = new ReportService(repository);
            reportService.Add(new Report()
            {
                Id = Guid.Parse("22e34370-ee6f-415c-a177-159e87a2b4d8")
            });
            applicationDbContext.SaveChanges();
            reportService.Remove(Guid.Parse("22e34370-ee6f-415c-a177-159e87a2b4d8"));
            Assert.Equal(0, applicationDbContext.Reports.Count());
        }
Esempio n. 7
0
        public void UpdateReportTests()
        {
            var builder = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            applicationDbContext = new ApplicationDbContext(builder.Options, configuration);
            repository           = new Repository <Report>(applicationDbContext);
            reportService        = new ReportService(repository);
            reportService.Add(new Report()
            {
                Id = Guid.Parse("5df72e56-a5af-4fcb-8151-5d7812640dc8")
            });
            applicationDbContext.SaveChanges();
            Report reports = applicationDbContext.Reports.SingleOrDefault(s => s.Id == Guid.Parse("5df72e56-a5af-4fcb-8151-5d7812640dc8"));

            reportService.Update(reports);
            Assert.Equal(1, applicationDbContext.Reports.Count());
        }
Esempio n. 8
0
        public async Task RegisterChatServer(string serverName)
        {
            var server = await ServerService.Get(Context.Guild.Id, serverName);

            if (server == null)
            {
                await ReplyAsync("Server does not exist!");

                return;
            }

            var reportServer = await ReportService.Get(server.Id, Context.Channel.Id);

            if (reportServer != null)
            {
                await ReplyAsync("Report server is already registered here!");

                return;
            }

            await ReportService.Add(server, Context.Channel.Id);

            await ReplyAsync("Report server has been registered!");
        }
Esempio n. 9
0
 public Report Add(int id, Report report)
 {
     return(_reportService.Add(report));
 }
Esempio n. 10
0
 public Report Add(int id, string reportText)
 {
     return(_reportService.Add(id, reportText));
 }
Esempio n. 11
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Report report = null;

            using (new UnitOfWorkScope())
            {
                ReportService      service            = new ReportService();
                ReportFieldService reportFieldService = new ReportFieldService();

                int reportId = int.Parse(hfReportId.Value);

                if (reportId == 0)
                {
                    report          = new Report();
                    report.IsSystem = false;
                }
                else
                {
                    report = service.Get(reportId);
                }

                report.Name         = tbName.Text;
                report.Description  = tbDescription.Text;
                report.CategoryId   = cpCategory.SelectedValueAsInt();
                report.EntityTypeId = ddlEntityType.SelectedValueAsInt();
                report.DataViewId   = ddlDataView.SelectedValueAsInt();

                if (!Page.IsValid)
                {
                    return;
                }

                if (!report.IsValid)
                {
                    // Controls will render the error messages
                    return;
                }

                RockTransactionScope.WrapTransaction(() =>
                {
                    // delete all the reportFields so we can cleanly add them
                    foreach (var reportField in report.ReportFields.ToList())
                    {
                        var field = reportFieldService.Get(reportField.Guid);
                        reportFieldService.Delete(field, this.CurrentPersonId);
                        reportFieldService.Save(field, this.CurrentPersonId);
                    }

                    report.ReportFields.Clear();

                    var allPanelWidgets = phReportFields.ControlsOfTypeRecursive <PanelWidget>();
                    int displayOrder    = 0;
                    foreach (var panelWidget in allPanelWidgets)
                    {
                        string hfReportFieldTypeID    = panelWidget.ID + "_hfReportFieldType";
                        HiddenField hfReportFieldType = phReportFields.ControlsOfTypeRecursive <HiddenField>().First(a => a.ID == hfReportFieldTypeID);

                        string hfFieldSelectionID    = panelWidget.ID + "_hfFieldSelection";
                        HiddenField hfFieldSelection = phReportFields.ControlsOfTypeRecursive <HiddenField>().First(a => a.ID == hfFieldSelectionID);

                        ReportFieldType reportFieldType = hfReportFieldType.Value.ConvertToEnum <ReportFieldType>();
                        string fieldSelection           = hfFieldSelection.Value;
                        ReportField reportField         = new ReportField();
                        reportField.ReportFieldType     = reportFieldType;

                        string showInGridCheckBoxId     = string.Format("{0}_showInGridCheckBox", panelWidget.ID);
                        RockCheckBox showInGridCheckBox = phReportFields.ControlsOfTypeRecursive <RockCheckBox>().First(a => a.ID == showInGridCheckBoxId);
                        reportField.ShowInGrid          = showInGridCheckBox.Checked;

                        string columnHeaderTextTextBoxId    = string.Format("{0}_columnHeaderTextTextBox", panelWidget.ID);
                        RockTextBox columnHeaderTextTextBox = phReportFields.ControlsOfTypeRecursive <RockTextBox>().First(a => a.ID == columnHeaderTextTextBoxId);
                        reportField.ColumnHeaderText        = columnHeaderTextTextBox.Text;

                        reportField.Order = displayOrder++;

                        if (reportFieldType == ReportFieldType.DataSelectComponent)
                        {
                            reportField.DataSelectComponentEntityTypeId = fieldSelection.AsInteger();

                            string dataSelectComponentTypeName      = EntityTypeCache.Read(reportField.DataSelectComponentEntityTypeId ?? 0).GetEntityType().FullName;
                            DataSelectComponent dataSelectComponent = Rock.Reporting.DataSelectContainer.GetComponent(dataSelectComponentTypeName);

                            string placeHolderId  = string.Format("{0}_phDataSelectControls", panelWidget.ID);
                            var placeHolder       = phReportFields.ControlsOfTypeRecursive <PlaceHolder>().Where(a => a.ID == placeHolderId).FirstOrDefault();
                            reportField.Selection = dataSelectComponent.GetSelection(placeHolder.Controls.OfType <Control>().ToArray());
                        }
                        else
                        {
                            reportField.Selection = fieldSelection;
                        }

                        report.ReportFields.Add(reportField);
                    }

                    if (report.Id.Equals(0))
                    {
                        service.Add(report, CurrentPersonId);
                    }

                    service.Save(report, CurrentPersonId);
                });
            }

            var qryParams = new Dictionary <string, string>();

            qryParams["ReportId"] = report.Id.ToString();
            NavigateToPage(RockPage.Guid, qryParams);
        }