Esempio n. 1
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Job").ToInputLogString());
            try
            {
                _commonFacade   = new CommonFacade();
                _commPoolFacade = new CommPoolFacade();

                ViewBag.jobstatus = _commPoolFacade.GetJobStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.channel   = _commPoolFacade.GetChannelWithEmailSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.srstatus  = _commPoolFacade.GetSRStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);

                JobViewModel jobVM = new JobViewModel();
                jobVM.SearchFilter = new CommPoolSearchFilter
                {
                    FirstName = string.Empty,
                    LastName  = string.Empty,
                    JobStatus = null,
                    Channel   = null,
                    Subject   = string.Empty,
                    From      = string.Empty,
                    DateFrom  = string.Empty,
                    DateTo    = string.Empty,
                    ActionBy  = string.Empty,
                    SRId      = string.Empty,
                    SRStatus  = null,
                    CreatorSR = string.Empty,
                    OwnerSR   = string.Empty,
                    User      = null,
                    PageNo    = 1,
                    PageSize  = _commonFacade.GetPageSizeStart(),
                    SortField = "JobId",
                    SortOrder = "DESC"
                };

                var defSearch = _commonFacade.GetShowhidePanelByUserId(this.UserInfo, Constants.Page.CommunicationPage);

                if (defSearch != null)
                {
                    jobVM.IsSelected = defSearch.IsSelectd ? "1" : "0";
                }
                else
                {
                    jobVM.IsSelected = "0";
                }

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

                return(View(jobVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Job").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Esempio n. 2
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch Product").ToInputLogString());

            try
            {
                _commonFacade   = new CommonFacade();
                _commPoolFacade = new CommPoolFacade();

                var statusList = _commPoolFacade.GetSRStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.srstatus = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

                ProductViewModel productVM = new ProductViewModel();
                productVM.SearchFilter = new ProductSearchFilter
                {
                    ProductGroupId = null,
                    ProductId      = null,
                    CampaignId     = null,
                    TypeId         = null,
                    AreaId         = null,
                    SubAreaId      = null,
                    FromSRStatus   = null,
                    ToSRStatus     = null,
                    PageNo         = 1,
                    PageSize       = _commonFacade.GetPageSizeStart(),
                    SortField      = "ProductGroup",
                    SortOrder      = "DESC"
                };

                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("InitSearch Product").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Esempio n. 3
0
        public ActionResult InitEdit(string jsonData = "{}")
        {
            ProductViewModel productVM = null;

            _commPoolFacade = new CommPoolFacade();

            var toRTStatuses = new Dictionary <string, string>();
            var fromStatuses = _commPoolFacade.GetSRStatusSelectList();
            var toLFStatuses = new Dictionary <string, string>(fromStatuses);
            ProductSearchFilter searchFilter = JsonConvert.DeserializeObject <ProductSearchFilter>(jsonData);

            if (TempData["productVM"] != null)
            {
                productVM = (ProductViewModel)TempData["productVM"];

                if (productVM.ToSRStatusRightId != null && productVM.ToSRStatusRightId.Count > 0)
                {
                    foreach (var s in productVM.ToSRStatusRightId)
                    {
                        var statusId   = s.ConvertToString();
                        var statusName = toLFStatuses[statusId];
                        toLFStatuses.RemoveByValue(statusId);
                        toRTStatuses.Add(statusId, statusName);
                    }
                }
            }
            else
            {
                productVM = new ProductViewModel(searchFilter);

                if (searchFilter != null)
                {
                    _productFacade = new ProductFacade();
                    ProductSREntity product = _productFacade.GetProduct(searchFilter);

                    if (product != null)
                    {
                        productVM.FromSRStatusId   = product.FromSRStatusId;
                        productVM.ProductGroupId   = product.ProductGroupId;
                        productVM.ProductGroupName = product.ProductGroupName;
                        productVM.ProductId        = product.ProductId;
                        productVM.ProductName      = product.ProductName;
                        productVM.CampaignId       = product.CampaignId;
                        productVM.CampaignName     = product.CampaignName;
                        productVM.TypeId           = product.TypeId;
                        productVM.TypeName         = product.TypeName;
                        productVM.AreaId           = product.AreaId;
                        productVM.AreaName         = product.AreaName;
                        productVM.SubAreaId        = product.SubAreaId;
                        productVM.SubAreaName      = product.SubAreaName;
                        productVM.IsEdit           = product.IsEdit;

                        productVM.CreateUser  = product.CreateUser != null ? product.CreateUser.FullName : "";
                        productVM.CreatedDate = product.CreatedDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                        productVM.UpdateDate  = product.Updatedate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                        productVM.UpdateUser  = product.UpdateUser != null ? product.UpdateUser.FullName : "";

                        toRTStatuses = product.ToSRStatusList.ToDictionary(x => x.SRStatusId.ConvertToString(), x => x.SRStatusName);
                        productVM.ToSRStatusRightList = new MultiSelectList(toRTStatuses, "Key", "Value");

                        foreach (var s in toRTStatuses)
                        {
                            toLFStatuses.RemoveByValue(s.Key);
                        }
                    }
                }
            }

            productVM.FromStatusList      = new SelectList((IEnumerable)fromStatuses, "Key", "Value", string.Empty);
            productVM.ToSRStatusLeftList  = new MultiSelectList(toLFStatuses, "Key", "Value");
            productVM.ToSRStatusRightList = new MultiSelectList(toRTStatuses, "Key", "Value");

            if (productVM.IsEdit == false)
            {
                // default UserLogin
                if (this.UserInfo != null)
                {
                    var today = DateTime.Now;
                    productVM.CreateUser  = this.UserInfo.FullName;
                    productVM.CreatedDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    productVM.UpdateDate  = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    productVM.UpdateUser  = this.UserInfo.FullName;
                }
            }


            return(View("~/Views/Product/Edit.cshtml", productVM));
        }