public ActionResult InitView(int attachmentId, string documentLevel) { Logger.Info(_logMsg.Clear().SetPrefixMsg("InitView Attachment").Add("AttachmentId", attachmentId). Add("DocumentLevel", documentLevel).ToInputLogString()); try { _customerFacade = new CustomerFacade(); var attachVM = new AttachViewModel(); AttachmentEntity selectedAttach = _customerFacade.GetAttachmentByID(attachmentId, documentLevel); if (selectedAttach != null) { attachVM.AttachmentId = selectedAttach.AttachmentId; 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.CreateUserFullName = selectedAttach.CreateUserFullName; attachVM.AttachTypeDisplay = StringHelpers.ConvertListToString(selectedAttach.AttachTypeList.Select(x => x.Name).ToList <object>(), ", "); } TempData["FILE_DOWNLOAD"] = selectedAttach; return(PartialView("~/Views/Document/_ViewAttachment.cshtml", attachVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("InitView Attachment").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
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()))); } }