public virtual JsonResult Upload(long id, AwbFileType 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, AwbFileType type) { var names = _files.GetNames(id, type); ViewBag.AwbId = id; return Json(names.Select(x => new { id = x.Id, name = x.Name }), JsonRequestBehavior.AllowGet); }
public virtual JsonResult Files(long id, AwbFileType type) { var names = _files.GetNames(id, type); ViewBag.AwbId = id; return(Json(names.Select(x => new { id = x.Id, name = x.Name }), JsonRequestBehavior.AllowGet)); }
public ReadOnlyCollection <FileInfo> GetNames(long awbId, AwbFileType type) { var idsTable = TableParameters.GeIdsTable("AwbIds", new[] { awbId }); var parameters = new TableParameters(new { TypeId = type }, idsTable); var infos = _executor.Array <dynamic>("[dbo].[AwbFile_GetNames]", parameters) .Select(x => new FileInfo { Id = x.Id, Name = x.Name }) .ToArray(); return(new ReadOnlyCollection <FileInfo>(infos)); }
public ReadOnlyCollection<FileInfo> GetNames(long awbId, AwbFileType type) { var idsTable = TableParameters.GeIdsTable("AwbIds", new[] { awbId }); var parameters = new TableParameters(new { TypeId = type }, idsTable); var infos = _executor.Array<dynamic>("[dbo].[AwbFile_GetNames]", parameters) .Select(x => new FileInfo { Id = x.Id, Name = x.Name }) .ToArray(); return new ReadOnlyCollection<FileInfo>(infos); }
public void Test_GetNames() { var bytes = _fixture.Create <byte[]>(); var name = _fixture.CreateMany <string>(2).OrderBy(x => x).ToArray(); const AwbFileType fileType = (AwbFileType)(-1); var id1 = _repository.Add(TestConstants.TestAwbId, fileType, name[0], bytes); var id2 = _repository.Add(TestConstants.TestAwbId, fileType, name[1], bytes); var names = _repository.GetNames(TestConstants.TestAwbId, 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]); }
private static void Insert(SqlConnection filesDb, long id, AwbFileType fileType, string fileName, byte[] fileData) { if (string.IsNullOrEmpty(fileName) || fileData == null) { return; } filesDb.Execute(@" INSERT [dbo].[AwbFile] ([AwbId], [Data], [Name], [TypeId]) VALUES (@AwbId, @Data, @Name, @TypeId)" , new { AwbId = id, TypeId = fileType, Name = fileName, Data = fileData }); }
private static void Insert(SqlConnection filesDb, long id, AwbFileType fileType, string fileName, byte[] fileData) { if(string.IsNullOrEmpty(fileName) || fileData == null) { return; } filesDb.Execute(@" INSERT [dbo].[AwbFile] ([AwbId], [Data], [Name], [TypeId]) VALUES (@AwbId, @Data, @Name, @TypeId)", new { AwbId = id, TypeId = fileType, Name = fileName, Data = fileData }); }
public ReadOnlyDictionary<long, ReadOnlyCollection<FileInfo>> GetInfo(long[] awbIds, AwbFileType type) { var idsTable = TableParameters.GeIdsTable("AwbIds", awbIds); var parameters = new TableParameters(new { TypeId = type }, idsTable); var dictionary = _executor.Array<dynamic>("[dbo].[AwbFile_GetNames]", parameters) .GroupBy(x => (long)x.AwbId) .ToDictionary(a => a.Key, a => { var infos = a.Select(x => new FileInfo { Id = x.Id, Name = x.Name }).ToArray(); return new ReadOnlyCollection<FileInfo>(infos); }); return new ReadOnlyDictionary<long, ReadOnlyCollection<FileInfo>>(dictionary); }
private FileHolder GetFileHolder(long awbId, AwbFileType awbFileType) { var name = GetNames(awbId, awbFileType).FirstOrDefault(); return(name != null?Get(name.Id) : null); }
public long Add(long awbId, AwbFileType type, string name, byte[] data) { return _executor.Query<long>("[dbo].[AwbFile_Add]", new { awbId, TypeId = type, name, data }); }
private FileHolder GetFileHolder(long awbId, AwbFileType awbFileType) { var name = GetNames(awbId, awbFileType).FirstOrDefault(); return name != null ? Get(name.Id) : null; }
private ReadOnlyDictionary<long, ReadOnlyCollection<FileInfo>> GetFileInfo(long[] ids, AwbFileType type) { return _files.GetInfo(ids, type); }
public virtual JsonResult Upload(long id, AwbFileType 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 ReadOnlyDictionary <long, ReadOnlyCollection <FileInfo> > GetInfo(long[] awbIds, AwbFileType type) { var idsTable = TableParameters.GeIdsTable("AwbIds", awbIds); var parameters = new TableParameters(new { TypeId = type }, idsTable); var dictionary = _executor.Array <dynamic>("[dbo].[AwbFile_GetNames]", parameters) .GroupBy(x => (long)x.AwbId) .ToDictionary(a => a.Key, a => { var infos = a.Select(x => new FileInfo { Id = x.Id, Name = x.Name }).ToArray(); return(new ReadOnlyCollection <FileInfo>(infos)); }); return(new ReadOnlyDictionary <long, ReadOnlyCollection <FileInfo> >(dictionary)); }
public long Add(long awbId, AwbFileType type, string name, byte[] data) { return(_executor.Query <long>("[dbo].[AwbFile_Add]", new { awbId, TypeId = type, name, data })); }
private ReadOnlyDictionary <long, ReadOnlyCollection <FileInfo> > GetFileInfo(long[] ids, AwbFileType type) { return(_files.GetInfo(ids, type)); }