Esempio n. 1
0
        public void GetEffective_Test()
        {
            //Arrage
            var strategicEffectives = Strategic.GetEffectives(context);

            //Act
            DateTime yesterday = DateTime.Now.AddDays(-1);

            //Assert
            foreach (var item in strategicEffectives)
            {
                Assert.IsTrue(item.EffectivePeriod.To >= yesterday);
                Assert.IsTrue(item.IsEffective);
            }
        }
        public JsonResult GetStrategics()
        {
            IList <Strategic>          strategics          = null;
            IList <StrategicViewModel> strategicViewModels = null;

            try
            {
                strategics          = Strategic.GetEffectives(SessionContext);
                strategicViewModels = strategics.Select(x => new StrategicViewModel
                {
                    ID   = x.ID,
                    Name = x.Name,
                }).ToList();
            }
            catch (Exception ex)
            {
                SessionContext.Log(0, this.pageID, 0, MessageException.StrategicMessage.Gets, MessageException.Fail(ex.Message));
            }
            return(Json(strategicViewModels, JsonRequestBehavior.AllowGet));
        }
        public ActionResult ProjectDetail(string p)
        {
            string  projectId = MapCipher.Decrypt(HttpUtility.HtmlDecode(p));
            Project project   = null;

            if (string.IsNullOrEmpty(projectId))
            {
                SessionContext.Log(0, this.PageID, 0, MessageException.ProjectMessage.GetDetail, MessageException.Null("The project id is emptry."));
                ViewBag.ErrorMessage = MessageException.Error;
            }

            try
            {
                project = SessionContext.PersistenceSession.Get <Project>(long.Parse(projectId));


                //ข้อมูลโครงการ
                ViewBag.MinistryCode = SessionContext.User.Organization.Code;
                ViewBag.MinistryName = SessionContext.User.Organization.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code);

                ViewBag.DepartmentCode = SessionContext.User.OrgUnit.Code;
                ViewBag.DepartmentName = SessionContext.User.OrgUnit.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code);

                //รหัสโครงการ ระบบจะต้องสร้างให้
                ViewBag.ProjectCode = project.ProjectNo;

                //ยุทธศาสตร์การจัดสรรงบประมาณ query effective only
                ViewBag.Strategics = Strategic.GetEffectives(SessionContext)
                                     .Select(x => new SelectListItem {
                    Text = x.Name, Value = x.ID.ToString(), Selected = x.ID == project.Strategic.ID
                });

                //ปีงบประมาณ
                IList <SelectListItem> datetimes = new List <SelectListItem>();
                for (int i = 2558; i < (DateTime.Now.Year + 543) + 5; i++)
                {
                    datetimes.Add(new SelectListItem {
                        Text = i.ToString(), Value = i.ToString(), Selected = project.BudgetYear == i.ToString()
                    });
                }
                ViewBag.Year = datetimes;

                //งบรายจ่ายประเภท
                List <SelectListItem> budgetTypes = new List <SelectListItem>();
                budgetTypes.Add(new SelectListItem {
                    Text = Project.BudgetTypeString(BudgetType.Action), Value = ((int)BudgetType.Action).ToString(), Selected = project.BudgetType == BudgetType.Action
                });
                budgetTypes.Add(new SelectListItem {
                    Text = Project.BudgetTypeString(BudgetType.Investment), Value = ((int)BudgetType.Investment).ToString(), Selected = project.BudgetType == BudgetType.Investment
                });
                budgetTypes.Add(new SelectListItem {
                    Text = Project.BudgetTypeString(BudgetType.Contribute), Value = ((int)BudgetType.Contribute).ToString(), Selected = project.BudgetType == BudgetType.Contribute
                });
                budgetTypes.Add(new SelectListItem {
                    Text = Project.BudgetTypeString(BudgetType.OtherExpenses), Value = ((int)BudgetType.OtherExpenses).ToString(), Selected = project.BudgetType == BudgetType.OtherExpenses
                });
                ViewBag.Expenditure = budgetTypes;
            }
            catch (Exception ex)
            {
                SessionContext.LogButNotFlush(0, this.PageID, 0, MessageException.ProjectMessage.GetDetail, MessageException.Fail(ex.Message));
                ViewBag.ErrorMessage = MessageException.Error;
            }

            return(View(project));
        }