Пример #1
0
        public ActionResult Upload(HttpPostedFileBase file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            var data = new byte[file.ContentLength];

            file.InputStream.Read(data, 0, file.ContentLength);

            var contentType = file.ContentType;

            if (contentType == "application/octet-stream")
            {
                contentType = MimeMapping.GetMimeMapping(file.FileName);
            }

            var service  = new ScribeService(Database, null, null, GetCurrentUser());
            var fileData = new FileView
            {
                Name = Path.GetFileName(file.FileName),
                Type = contentType,
                Data = data
            };

            service.SaveFile(fileData);
            Database.SaveChanges();

            return(new JsonNetResult(service.GetFiles(new PagedRequest {
                PerPage = int.MaxValue
            })));
        }
Пример #2
0
        public ActionResult Files()
        {
            var service = new ScribeService(Database, null, null, GetCurrentUser());

            return(View(service.GetFiles(new PagedRequest {
                PerPage = int.MaxValue
            })));
        }
Пример #3
0
 public ActionResult New(string suggestedTitle)
 {
     return(View("Edit", new PageView
     {
         Title = suggestedTitle,
         Files = _service.GetFiles(new PagedRequest {
             PerPage = int.MaxValue
         }).Results,
         Pages = _service.GetPages(new PagedRequest {
             PerPage = int.MaxValue
         }).Results.Select(x => new PageReference {
             Id = x.Id, Title = x.Title, TitleForLink = x.TitleForLink
         }).ToList()
     }));
 }
Пример #4
0
 public PagedResults <FileView> GetFiles(PagedRequest request)
 {
     return(_service.GetFiles(request));
 }