예제 #1
0
        public ActionResult List(int?customerId = null)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").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"));
                }

                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();

                ExistingProductViewModel productVM = new ExistingProductViewModel();
                productVM.CustomerInfo = custInfoVM;

                if (custInfoVM.CustomerId.HasValue)
                {
                    productVM.SearchFilter = new AccountSearchFilter
                    {
                        CustomerId = custInfoVM.CustomerId.Value,
                        PageNo     = 1,
                        PageSize   = _commonFacade.GetPageSizeStart(),
                        SortField  = "ProductGroup",
                        SortOrder  = "ASC"
                    };

                    productVM.AccountList = _customerFacade.GetAccountList(productVM.SearchFilter);
                    ViewBag.PageSize      = productVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList  = _commonFacade.GetPageSizeList();
                    ViewBag.Message       = string.Empty;
                }

                return(View(productVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
예제 #2
0
        public ActionResult List(string encryptedString)
        {
            int?customerId = encryptedString.ToCustomerId();

            Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("CustomerId", customerId).ToInputLogString());

            try
            {
                _commonFacade   = new CommonFacade();
                _customerFacade = new CustomerFacade();

                ExistingProductViewModel productVM  = new ExistingProductViewModel();
                CustomerInfoViewModel    custInfoVM = this.MappingCustomerInfoView(customerId.Value);
                productVM.CustomerInfo = custInfoVM;

                if (custInfoVM.CustomerId.HasValue)
                {
                    productVM.SearchFilter = new AccountSearchFilter
                    {
                        CustomerId = custInfoVM.CustomerId.Value,
                        PageNo     = 1,
                        PageSize   = _commonFacade.GetPageSizeStart(),
                        SortField  = "ProductGroup",
                        SortOrder  = "ASC"
                    };

                    productVM.AccountList = _customerFacade.GetAccountList(productVM.SearchFilter);
                    ViewBag.PageSize      = productVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList  = _commonFacade.GetPageSizeList();
                    ViewBag.Message       = string.Empty;
                }

                return(View(productVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("List ExistingProduct").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
예제 #3
0
        public ActionResult ExistingProductList(AccountSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("ExistingProductList").Add("CustomerId", searchFilter.CustomerId)
                        .ToInputLogString());

            try
            {
                if (ModelState.IsValid)
                {
                    _commonFacade   = new CommonFacade();
                    _customerFacade = new CustomerFacade();
                    ExistingProductViewModel productVM = new ExistingProductViewModel();
                    productVM.SearchFilter = searchFilter;

                    productVM.AccountList = _customerFacade.GetAccountList(productVM.SearchFilter);
                    ViewBag.PageSize      = productVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList  = _commonFacade.GetPageSizeList();

                    Logger.Info(_logMsg.Clear().SetPrefixMsg("ExistingProductList").ToSuccessLogString());
                    return(PartialView("~/Views/ExistingProduct/_ExistingProductList.cshtml", productVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("ExistingProductList").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }