public ActionResult Save(string id, IEnumerable <HttpPostedFileBase> attachments)
        {
            foreach (var file in attachments)
            {
                string fileName     = Path.GetFileName(file.FileName);
                string physicalPath =
                    AdditionalInfoManager.GetPhysicalPath(
                        Template,
                        new[]
                {
                    User.Identity.Name,
                    DateTime.Now.ToString("MM-dd-yy")
                });

                file.SaveAs(physicalPath + fileName);

                _portalMessage.AddAppendix(
                    User.Identity.Name,
                    id,
                    new DocumentAdditionalInfo
                {
                    FilePath = physicalPath + fileName,
                    InfoName = fileName,
                    _id      = ObjectId.GenerateNewId().ToString()
                });
            }

            return(Content(""));
        }
        public ActionResult SaveMessage(string messageId)
        {
            var statuses = new List <ViewDataUploadFilesResult>();

            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file         = Request.Files[i];
                string             fileName     = Path.GetFileName(file.FileName);
                string             physicalPath =
                    AdditionalInfoManager.GetPhysicalPath(
                        "messageAppendix/{1}/{0}/",
                        new[]
                {
                    User.Identity.Name,
                    DateTime.Now.ToString("MM-dd-yy")
                });

                file.SaveAs(physicalPath + fileName);
                var document = new DocumentAdditionalInfo
                {
                    FilePath = physicalPath + fileName,
                    InfoName = fileName,
                    _id      = ObjectId.GenerateNewId().ToString()
                };
                _portalMessage.AddAppendix(
                    User.Identity.Name,
                    messageId, document);
                statuses.Add(new ViewDataUploadFilesResult
                {
                    name          = fileName,
                    size          = file.ContentLength,
                    type          = file.ContentType,
                    url           = "/AdditionalInfo/DownloadNotesInfo?messageId=" + messageId + "&appendixId=" + document._id,
                    thumbnail_url = @"data:image/png;base64," + EncodeFile(physicalPath),
                    delete_type   = "GET",
                });
            }

            return(Json(statuses));
        }