Пример #1
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch News").ToInputLogString());

            try
            {
                _commonFacade = new CommonFacade();

                NewsViewModel newsVM = new NewsViewModel();
                newsVM.SearchFilter = new NewsSearchFilter
                {
                    Topic     = string.Empty,
                    PageNo    = 1,
                    PageSize  = _commonFacade.GetPageSizeStart(),
                    SortField = "AnnounceDate",
                    SortOrder = "DESC"
                };

                var statusList = _commonFacade.GetStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                newsVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

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

                return(View(newsVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch News").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 InitEdit(int?commPoolId = null)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit CommunicationPool").Add("CommPoolId", commPoolId).ToInputLogString());

            try
            {
                PoolViewModel poolVM = null;

                if (TempData["PoolVM"] != null)
                {
                    poolVM = (PoolViewModel)TempData["PoolVM"];
                }
                else
                {
                    poolVM = new PoolViewModel {
                        PoolId = commPoolId
                    };
                }

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

                var statusList = _commonFacade.GetStatusSelectList();
                poolVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);
                var replyMailList = _commonFacade.GetReplyMailSelectList();
                poolVM.ReplyMailList      = new SelectList((IEnumerable)replyMailList, "Key", "Value", string.Empty);
                poolVM.PoolEmailTemplates = _commPoolFacade.GetPoolEmailTemplates().Select(c => new SelectListItem {
                    Text = c.Name, Value = c.PoolEmailTemplateId + ""
                }).ToList();

                if (poolVM.PoolId != null)
                {
                    PoolEntity poolEntity = _commPoolFacade.GetPoolByID(poolVM.PoolId.Value);
                    poolVM.PoolName            = poolEntity.PoolName;
                    poolVM.PoolDesc            = poolEntity.PoolDesc;
                    poolVM.Email               = poolEntity.Email;
                    poolVM.Status              = poolEntity.Status;
                    poolVM.ReplyMail           = poolEntity.ReplyMail;
                    poolVM.PoolEmailTemplateId = poolEntity.EmailTemplateId;

                    poolVM.CreateUser  = poolEntity.CreateUser != null ? poolEntity.CreateUser.FullName : string.Empty;
                    poolVM.UpdateUser  = poolEntity.UpdateUser != null ? poolEntity.UpdateUser.FullName : string.Empty;
                    poolVM.CreatedDate =
                        poolEntity.CreatedDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    poolVM.UpdateDate =
                        poolEntity.Updatedate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);

                    var poolBranches = _commPoolFacade.GetPoolBranchList(poolVM.PoolId.Value);
                    poolVM.PoolBranchList = poolBranches;
                    poolVM.JsonBranch     = JsonConvert.SerializeObject(poolBranches);
                }
                else
                {
                    poolVM.PoolBranchList = _commPoolFacade.GetPoolBranchList(poolVM.SelectedBranch)
                                            .Where(x => x.IsDelete == false).ToList();

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

                return(View("~/Views/CommPool/Edit.cshtml", poolVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit CommunicationPool").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 InitEdit(int?relationshipId = null)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("IntEdit ContactRelationship").Add("RelationshipId", relationshipId).ToInputLogString());

            try
            {
                ContactViewModel contactVM = null;

                if (TempData["contactVM"] != null)
                {
                    contactVM = (ContactViewModel)TempData["contactVM"];
                }
                else
                {
                    contactVM = new ContactViewModel {
                        RelationshipId = relationshipId
                    };
                }

                _commonFacade = new CommonFacade();
                var statusList = _commonFacade.GetStatusSelectList();
                contactVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

                if (contactVM.RelationshipId != null)
                {
                    _customerFacade = new CustomerFacade();
                    RelationshipEntity relationshipEntity =
                        _customerFacade.GetRelationshipByID(contactVM.RelationshipId.Value);

                    contactVM.RelationshipId   = relationshipEntity.RelationshipId;
                    contactVM.RelationshipName = relationshipEntity.RelationshipName;
                    contactVM.RelationshipDesc = relationshipEntity.RelationshipDesc;
                    contactVM.Status           = relationshipEntity.Status;
                    contactVM.CreateUser       = relationshipEntity.CreateUserDisplay;
                    contactVM.UpdateUser       = relationshipEntity.UpdateUserDisplay;
                    contactVM.CreatedDate      =
                        relationshipEntity.CreatedDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    contactVM.UpdateDate =
                        relationshipEntity.Updatedate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                }
                else
                {
                    // default UserLogin
                    if (this.UserInfo != null)
                    {
                        var today = DateTime.Now;
                        contactVM.CreateUser  = this.UserInfo.FullName;
                        contactVM.CreatedDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                        contactVM.UpdateDate  = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                        contactVM.UpdateUser  = this.UserInfo.FullName;
                    }
                }

                return(View("~/Views/Contact/Edit.cshtml", contactVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("IntEdit ContactRelationship").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Пример #4
0
        public ActionResult InitEdit(int?newsId = null)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Edit News").Add("NewsId", newsId).ToInputLogString());

            NewsViewModel newsVM = null;

            if (TempData["NewsVM"] != null)
            {
                newsVM = (NewsViewModel)TempData["NewsVM"];
            }
            else
            {
                newsVM = new NewsViewModel {
                    NewsId = newsId
                };
            }

            _newsFacade   = new NewsFacade();
            _commonFacade = new CommonFacade();

            var statusList = _commonFacade.GetStatusSelectList();

            newsVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

            if (TempData["NewsVM"] == null && newsVM.NewsId != null)
            {
                NewsEntity newsEntity = _newsFacade.GetNewsByID(newsVM.NewsId.Value);
                newsVM.Topic        = newsEntity.Topic;
                newsVM.AnnounceDate = newsEntity.AnnounceDateDisplay;
                newsVM.ExpiryDate   = newsEntity.ExpiryDateDisplay;
                newsVM.Content      = newsEntity.Content;
                newsVM.FullName     = newsEntity.CreateUser.FullName;
                newsVM.Status       = newsEntity.Status;

                // User
                newsVM.CreateUser  = newsEntity.CreateUser != null ? newsEntity.CreateUser.FullName : "";
                newsVM.CreatedDate = newsEntity.CreatedDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                newsVM.UpdateDate  = newsEntity.UpdateDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                newsVM.UpdateUser  = newsEntity.UpdateUser != null ? newsEntity.UpdateUser.FullName : "";

                var newsBranches = _newsFacade.GetNewsBranchList(newsVM.NewsId.Value);
                newsVM.NewsBranchList = newsBranches;
                newsVM.JsonBranch     = JsonConvert.SerializeObject(newsBranches);

                var newsAttachments = _newsFacade.GetNewsAttachmentList(newsVM.NewsId.Value);
                newsVM.AttachmentList = newsAttachments;
                newsVM.JsonAttach     = JsonConvert.SerializeObject(newsAttachments);
            }
            else if (TempData["NewsVM"] == null)
            {
                // Default UserLogin
                if (this.UserInfo != null)
                {
                    newsVM.FullName = this.UserInfo.FullName; // ผู้ประกาศ

                    var today = DateTime.Now;
                    newsVM.CreateUser  = this.UserInfo.FullName;
                    newsVM.CreatedDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    newsVM.UpdateDate  = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    newsVM.UpdateUser  = this.UserInfo.FullName;
                }

                newsVM.NewsBranchList = _newsFacade.GetNewsBranchList(newsVM.SelectedBranch)
                                        .Where(x => x.IsDelete == false).ToList();
            }
            else
            {
                newsVM.NewsBranchList = _newsFacade.GetNewsBranchList(newsVM.SelectedBranch)
                                        .Where(x => x.IsDelete == false).ToList();
            }

            return(View("~/Views/News/Edit.cshtml", newsVM));
        }
Пример #5
0
        public ActionResult InitEdit(int?ConfigureUrlId = null)
        {
            ConfigurationViewModel configVM = null;

            if (TempData["configurationVM"] != null)
            {
                configVM = (ConfigurationViewModel)TempData["configurationVM"];
            }
            else
            {
                configVM = new ConfigurationViewModel {
                    ConfigureUrlId = ConfigureUrlId
                };
            }

            _commonFacade = new CommonFacade();
            var statusList = _commonFacade.GetStatusSelectList();

            configVM.StatusList = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

            #region "For show in hint"

            //ParameterEntity param = _commonFacade.GetCacheParamByName(Constants.ParameterName.RegexConfigIcon);
            //ParameterEntity paramSingleFileSize = _commonFacade.GetCacheParamByName(Constants.ParameterName.SingleFileSize);

            //int? limitSingleFileSize = paramSingleFileSize.ParamValue.ToNullable<int>();
            //var singleLimitSize = limitSingleFileSize.HasValue ? (limitSingleFileSize / 1048576) : 0;
            //ViewBag.UploadLimitType = string.Format(param.ParamDesc, singleLimitSize);

            #endregion

            _configFacade = new ConfigurationFacade();
            var menuList = _configFacade.GetAllMenu();
            configVM.MenuList = new SelectList((IEnumerable)menuList, "Key", "Value", string.Empty);

            List <RoleEntity> roles = _configFacade.GetAllRole();
            if (roles != null && roles.Count > 0)
            {
                configVM.RoleCheckBoxes = roles.Select(x => new CheckBoxes
                {
                    Value   = x.RoleId.ToString(),
                    Text    = x.RoleName,
                    Checked = false
                }).ToList();
            }

            if (configVM.ConfigureUrlId != null)
            {
                ConfigureUrlEntity configUrlEntity = _configFacade.GetConfigureURLById(configVM.ConfigureUrlId.Value);
                configVM.ConfigureUrlId = configUrlEntity.ConfigureUrlId;
                configVM.SystemName     = configUrlEntity.SystemName;
                configVM.Url            = configUrlEntity.Url;
                configVM.Status         = configUrlEntity.Status;
                configVM.MenuId         = configUrlEntity.Menu.MenuId;
                configVM.FileUrl        = configUrlEntity.ImageUrl;
                configVM.FontName       = configUrlEntity.FontName;

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

                if (configVM.RoleCheckBoxes != null && configUrlEntity.Roles != null)
                {
                    configVM.JsonRole = JsonConvert.SerializeObject(configUrlEntity.Roles);
                    configVM.RoleCheckBoxes.Where(x => configUrlEntity.Roles.Select(r => r.RoleId.ToString()).Contains(x.Value))
                    .ToList().ForEach(x => x.Checked = true);
                }
            }
            else
            {
                // default UserLogin
                if (this.UserInfo != null)
                {
                    var today = DateTime.Now;
                    configVM.CreateUser  = this.UserInfo.FullName;
                    configVM.CreatedDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    configVM.UpdateDate  = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    configVM.UpdateUser  = this.UserInfo.FullName;
                }
            }

            // List Font
            int refPageIndex = 0;
            configVM.FontList        = GetFont(null, null, ref refPageIndex).FontList;
            configVM.PageIndexOfFont = refPageIndex;

            return(View("~/Views/Configuration/Edit.cshtml", configVM));
        }