public virtual JsonResult Upload(long id, ApplicationFileType type, HttpPostedFileBase file) { var bytes = file.GetBytes(); var fileId = _files.Add(id, type, file.FileName, bytes); AddFileUploadEvent(id, TypesMapping[type], file.FileName, bytes); return(Json(new { id = fileId })); }
public virtual JsonResult Files(long id, ApplicationFileType type) { var names = _files.GetNames(id, type); ViewBag.ApplicationId = id; return(Json(names.Select(x => new { id = x.Id, name = x.Name }), JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Files(long id, ApplicationFileType type) { var names = _files.GetNames(id, type); ViewBag.ApplicationId = id; return Json(names.Select(x => new { id = x.Id, name = x.Name }), JsonRequestBehavior.AllowGet); }
public ReadOnlyCollection <FileInfo> GetNames(long applicationId, ApplicationFileType type) { var idsTable = TableParameters.GeIdsTable("AppIds", new[] { applicationId }); var parameters = new TableParameters(new { TypeId = type }, idsTable); var names = _executor.Array <dynamic>("[dbo].[ApplicationFile_GetNames]", parameters) .Select(x => new FileInfo { Name = x.Name, Id = x.Id }).ToArray(); return(new ReadOnlyCollection <FileInfo>(names)); }
public ReadOnlyCollection<FileInfo> GetNames(long applicationId, ApplicationFileType type) { var idsTable = TableParameters.GeIdsTable("AppIds", new[] { applicationId }); var parameters = new TableParameters(new { TypeId = type }, idsTable); var names = _executor.Array<dynamic>("[dbo].[ApplicationFile_GetNames]", parameters) .Select(x => new FileInfo { Name = x.Name, Id = x.Id }).ToArray(); return new ReadOnlyCollection<FileInfo>(names); }
public void Test_GetNames() { var bytes = _fixture.Create <byte[]>(); var name = _fixture.CreateMany <string>(2).OrderBy(x => x).ToArray(); const ApplicationFileType fileType = (ApplicationFileType)(-1); var id1 = _repository.Add(TestConstants.TestApplicationId, fileType, name[0], bytes); var id2 = _repository.Add(TestConstants.TestApplicationId, fileType, name[1], bytes); var names = _repository.GetNames(TestConstants.TestApplicationId, fileType); names.Should().HaveCount(2); names[0].Id.ShouldBeEquivalentTo(id1); names[1].Id.ShouldBeEquivalentTo(id2); names[0].Name.ShouldBeEquivalentTo(name[0]); names[1].Name.ShouldBeEquivalentTo(name[1]); }
public static string ToString(this ApplicationFileType fileType) { switch (fileType) { case ApplicationFileType.Unknown: return("Unknown"); case ApplicationFileType.Bnk: return("bnk"); case ApplicationFileType.Png: return("png"); case ApplicationFileType.Pdf: return("pdf"); default: throw new ArgumentOutOfRangeException("fileType"); } }
public ReadOnlyDictionary<long, ReadOnlyCollection<FileInfo>> GetInfo(long[] applicationIds, ApplicationFileType type) { var idsTable = TableParameters.GeIdsTable("AppIds", applicationIds); var parameters = new TableParameters(new { TypeId = type }, idsTable); var dictionary = _executor.Array<dynamic>("[dbo].[ApplicationFile_GetNames]", parameters) .GroupBy(x => (long)x.ApplicationId) .ToDictionary(a => a.Key, a => { var names = a.Select(x => new FileInfo { Id = x.Id, Name = x.Name }).ToArray(); return new ReadOnlyCollection<FileInfo>(names); }); return new ReadOnlyDictionary<long, ReadOnlyCollection<FileInfo>>(dictionary); }
internal ApplicationFileState(string relativePath, ApplicationFileType type, string hash) { RelativePath = relativePath; Type = type; Hash = hash; }
public virtual JsonResult Upload(long id, ApplicationFileType type, HttpPostedFileBase file) { var bytes = file.GetBytes(); var fileId = _files.Add(id, type, file.FileName, bytes); AddFileUploadEvent(id, TypesMapping[type], file.FileName, bytes); return Json(new { id = fileId }); }
public long Add(long applicationId, ApplicationFileType type, string name, byte[] data) { return(_executor.Query <long>("[dbo].[ApplicationFile_Add]", new { applicationId, TypeId = type, name, data })); }
public ReadOnlyDictionary <long, ReadOnlyCollection <FileInfo> > GetInfo(long[] applicationIds, ApplicationFileType type) { var idsTable = TableParameters.GeIdsTable("AppIds", applicationIds); var parameters = new TableParameters(new { TypeId = type }, idsTable); var dictionary = _executor.Array <dynamic>("[dbo].[ApplicationFile_GetNames]", parameters) .GroupBy(x => (long)x.ApplicationId) .ToDictionary(a => a.Key, a => { var names = a.Select(x => new FileInfo { Id = x.Id, Name = x.Name }).ToArray(); return(new ReadOnlyCollection <FileInfo>(names)); }); return(new ReadOnlyDictionary <long, ReadOnlyCollection <FileInfo> >(dictionary)); }
public long Add(long applicationId, ApplicationFileType type, string name, byte[] data) { return _executor.Query<long>("[dbo].[ApplicationFile_Add]", new { applicationId, TypeId = type, name, data }); }