Example #1
0
        public IHttpActionResult Upload(string businessId)
        {
            Guid ret = Guid.Empty;

            if (string.IsNullOrEmpty(businessId) || !Guid.TryParse(businessId, out ret))
            {
                throw new BizException("参数错误");
            }
            var attachment = new Models.Attachment();
            var setting    = AttachmentOperator.Instance.CommonSetting();
            var model      = AttachmentOperator.Instance.CommonUpload(businessId, setting.Item1, setting.Item2, setting.Item3);

            AttachmentOperator.Instance.AddModel(model);
            attachment.ConvertEntity(model);
            return(BizResult(attachment));
        }
Example #2
0
        public IHttpActionResult LoadAttachmentList(string businessId, string businessType)
        {
            Guid ret = Guid.Empty;

            if (string.IsNullOrEmpty(businessId) || !Guid.TryParse(businessId, out ret) || string.IsNullOrEmpty(businessType))
            {
                throw new BizException("参数错误");
            }
            var attachmentList = AttachmentOperator.Instance.GetList(businessType, businessId);
            var attachments    = attachmentList.Select(x =>
            {
                var attachment = new Models.Attachment();
                attachment.ConvertEntity(x);
                return(attachment);
            }).ToList();

            return(BizResult(attachments));
        }
Example #3
0
        public IHttpActionResult Get(string attachmentId)
        {
            Guid ret = Guid.Empty;

            if (string.IsNullOrEmpty(attachmentId) || !Guid.TryParse(attachmentId, out ret))
            {
                throw new BizException("参数错误");
            }
            var finder = AttachmentOperator.Instance.GetModel(attachmentId);

            if (finder == null)
            {
                throw new BizException("附件查找失败");
            }
            Models.Attachment attachment = new Models.Attachment();
            attachment.ConvertEntity(finder);
            return(BizResult(attachment));
        }