コード例 #1
0
ファイル: ActivityController.cs プロジェクト: KKPBank/CSM
        public ActionResult List()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch ActivityLog").ToInputLogString());

            try
            {
                CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel();

                if (TempData["CustomerInfo"] != null)
                {
                    custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"];
                    TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab
                }
                else
                {
                    return(RedirectToAction("Search", "Customer"));
                }

                ActivityViewModel activityVM = new ActivityViewModel();
                if (custInfoVM.CustomerId != null)
                {
                    activityVM.CustomerInfo = custInfoVM;
                }

                _commonFacade   = new CommonFacade();
                _activityFacade = new ActivityFacade();

                var subsType = custInfoVM.SubscriptType;

                var today                  = DateTime.Today;
                var month                  = new DateTime(today.Year, today.Month, 1);
                var numMonthsActivity      = _commonFacade.GetNumMonthsActivity();
                var activityStartDateValue = month.AddMonths(-1 * numMonthsActivity); //"2015-01-01".ParseDateTime("yyyy-MM-dd");

                activityVM.SearchFilter = new ActivitySearchFilter
                {
                    ActivityStartDateTime = activityStartDateValue.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime),
                    ActivityEndDateTime   = DateTime.Now.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime),
                    CardNo       = custInfoVM.CardNo,
                    SubsTypeCode = subsType != null ? subsType.SubscriptTypeCode : null,
                    PageNo       = 1,
                    PageSize     = _commonFacade.GetPageSizeStart(),
                    SortField    = "ActivityID",
                    SortOrder    = "DESC"
                };

                ViewBag.PageSize     = activityVM.SearchFilter.PageSize;
                ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                ViewBag.Message      = string.Empty;

                return(View(activityVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch ActivityLog").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }