Пример #1
0
        public ActionResult InitEdit(string jsonData)
        {
            _commonFacade = new CommonFacade();

            #region "For show in hint"

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

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

            #endregion

            List <DocumentTypeEntity> docTypeList = null;
            var attachVM = JsonConvert.DeserializeObject <AttachViewModel>(jsonData);

            if (attachVM.ListIndex != null)
            {
                AttachmentEntity selectedAttach = attachVM.AttachmentList[attachVM.ListIndex.Value];
                attachVM.Filename   = selectedAttach.Filename;
                attachVM.DocName    = selectedAttach.Name;
                attachVM.DocDesc    = selectedAttach.Description;
                attachVM.ExpiryDate = selectedAttach.ExpiryDateDisplay;
                docTypeList         = _commonFacade.GetDocumentTypeList(selectedAttach.AttachTypeList, Constants.DocumentCategory.Announcement);
            }
            else
            {
                docTypeList = _commonFacade.GetActiveDocumentTypes(Constants.DocumentCategory.Announcement);
            }

            if (docTypeList != null)
            {
                attachVM.DocTypeCheckBoxes = docTypeList.Select(x => new CheckBoxes
                {
                    Value   = x.DocTypeId.ToString(),
                    Text    = x.Name,
                    Checked = x.IsChecked
                }).ToList();
            }

            return(PartialView("~/Views/Attachment/_AttachEdit.cshtml", attachVM));
        }
Пример #2
0
        public ActionResult InitEdit(int?attachmentId, int?customerId, string documentLevel)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit Attachment").Add("AttachmentId", attachmentId)
                        .Add("CustomerId", customerId).Add("DocumentLevel", documentLevel).ToInputLogString());

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

                #region "For show in hint"

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

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

                #endregion

                var attachVM = new AttachViewModel();
                List <DocumentTypeEntity> docTypeList = null;

                if (attachmentId.HasValue)
                {
                    AttachmentEntity selectedAttach = _customerFacade.GetAttachmentByID(attachmentId.Value, documentLevel);
                    attachVM.Filename   = selectedAttach.Filename;
                    attachVM.DocName    = selectedAttach.Name;
                    attachVM.DocDesc    = selectedAttach.Description;
                    attachVM.ExpiryDate = selectedAttach.ExpiryDateDisplay;
                    attachVM.CustomerId = selectedAttach.CustomerId;
                    attachVM.Status     = selectedAttach.Status;

                    attachVM.AttachmentId = attachmentId.Value;

                    docTypeList = _commonFacade.GetDocumentTypeList(selectedAttach.AttachTypeList, Constants.DocumentCategory.Customer);
                }
                else
                {
                    attachVM.CustomerId = customerId; // case new
                    docTypeList         = _commonFacade.GetActiveDocumentTypes(Constants.DocumentCategory.Customer);
                }

                if (docTypeList != null)
                {
                    attachVM.JsonAttachType    = JsonConvert.SerializeObject(docTypeList);
                    attachVM.DocTypeCheckBoxes = docTypeList.Select(x => new CheckBoxes
                    {
                        Value   = x.DocTypeId.ToString(),
                        Text    = x.Name,
                        Checked = x.IsChecked
                    }).ToList();
                }

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

                return(PartialView("~/Views/Document/_EditAttachment.cshtml", attachVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitEdit Attachment").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }