Пример #1
0
        public ActionResult PoolBranchList(PoolViewModel poolVM)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Get PoolBranch List").Add("PoolName", poolVM.JsonBranch).ToInputLogString());

            try
            {
                _commPoolFacade       = new CommPoolFacade();
                poolVM.PoolBranchList = _commPoolFacade.GetPoolBranchList(poolVM.SelectedBranch)
                                        .Where(x => x.IsDelete == false).ToList();

                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get PoolBranch List").ToSuccessLogString());
                return(PartialView("~/Views/CommPool/_PoolBranchList.cshtml", poolVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Get PoolBranch List").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())));
            }
        }