Пример #1
0
 /// <summary>
 /// ViewModel 转 DataModel
 /// </summary>
 /// <param name="attachmentVModel"></param>
 /// <returns></returns>
 public static AttachmentInfo AttachmentVModelToInfo(AttachmentVModel attachmentVModel)
 {
     if (attachmentVModel == null)
     {
         return(new AttachmentInfo());
     }
     return(new AttachmentInfo
     {
         Id = attachmentVModel.Id,
         FileName = attachmentVModel.FileName,
         FileTitle = attachmentVModel.FileTitle,
         Description = attachmentVModel.Description,
         Type = attachmentVModel.Type,
         Width = attachmentVModel.Width,
         Height = attachmentVModel.Height,
         FileSize = attachmentVModel.FileSize,
         IsShow = attachmentVModel.IsShow,
         AId = attachmentVModel.AId,
         Score = attachmentVModel.Score,
         State = attachmentVModel.State,
         UserId = attachmentVModel.UserId,
         Guid = attachmentVModel.Guid,
         InTime = attachmentVModel.InTime,
         BType = attachmentVModel.BType,
         LocalPath = attachmentVModel.LocalPath,
         VirtualPath = attachmentVModel.VirtualPath
     });
 }
Пример #2
0
        public JsonResult Add(AttachmentVModel model)
        {
            var result = new JsonResultModel();

            if (ModelState.IsValid)
            {
                //add
                result.ResultState = Attachments.AddAttachment(Attachments.AttachmentVModelToInfo(model)) > 0;
            }
            else
            {
                result.ResultState = false;
                result.Message     = ModelStateHelper.GetAllErrorMessage(ModelState);
            }

            return(Json(result));
        }
Пример #3
0
        public ActionResult Add()
        {
            var vm = new AttachmentVModel();

            return(View(vm));
        }