Ejemplo n.º 1
0
 public bool IsValidImageId(Guid imageId) 
 {
     using (var context = new AppCampusContext())
     {
         return context.Images.Any(i => i.Id == imageId);
     }
 }
 public Screenshot Find(Guid screenshotId) 
 {
     using (var context = new AppCampusContext())
     {
         var screenshotTable = context.Screenshots.First(x => x.Id == screenshotId);
         return Screenshot.From(screenshotTable.Id, screenshotTable.Base64ImageString, screenshotTable.DeviceId, screenshotTable.CreatedDate);
     }
 }
Ejemplo n.º 3
0
        public byte[] GetFile(Guid softwareFileId)
        {
            LogFileTable logFile;

            using (var context = new AppCampusContext())
            {
                logFile = context.LogFiles.Find(softwareFileId);
            }

            return logFile.Binary;
        }
        public bool HasScreenshot(Guid screenshotId) 
        {
            using (var context = new AppCampusContext())
            {
                var screenshotTable = context.Screenshots.FirstOrDefault(x => x.Id == screenshotId);

                if (screenshotTable == null)
                {
                    return false;
                }
            }

            return true;
        }
Ejemplo n.º 5
0
        public string GetNameFromId(Guid imageId)
        {
            using (var context = new AppCampusContext())
            {
                var image = context.Images.Find(imageId);

                if (image == null)
                {
                    throw new ArgumentNullException("imageId", String.Format("No Image with Id = {0} exists.", imageId));
                }

                return image.Name;
            }
        }
        public string GetFileName(Guid softwareFileId)
        {
            using (var context = new AppCampusContext())
            {
                var softwareFile = context.SoftwareFiles.Select(x => new { Id = x.Id, FileName = x.FileName }).SingleOrDefault(x => x.Id == softwareFileId);

                if (softwareFile == null)
                {
                    throw new ArgumentOutOfRangeException("softwareFileId", String.Format("There is no software file with id '{0}'", softwareFileId));
                }

                return softwareFile.FileName;
            }
        }
 public void StoreScreenshot(Screenshot screenshot)
 {
     using (var context = new AppCampusContext())
     {
         context.Screenshots.Add(
             new ScreenshotTable()
             {
                 Id = screenshot.Id,
                 DeviceId = screenshot.DeviceId,
                 CreatedDate = DateTime.UtcNow,
                 Base64ImageString = screenshot.Base64ImageString
             });
         context.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public Guid AddImage(string base64Image, string imageName) 
 {
     using (var context = new AppCampusContext())
     {
         ImageTable imageTable = context.Images.Add(
             new ImageTable() 
             {
                 Id = CombIdentityFactory.GenerateIdentity(),
                 Base64Image = base64Image,
                 CreatedDate = DateTime.Now,
                 Name = imageName
             });
         context.SaveChanges();
         return imageTable.Id;
     }
 }
Ejemplo n.º 9
0
        public Guid SaveFile(byte[] file)
        {
            var logFile = new LogFileTable()
            {
                Id = CombIdentityFactory.GenerateIdentity(),
                Binary = file
            };

            using (var context = new AppCampusContext())
            {
                context.LogFiles.Add(logFile);

                context.SaveChanges();
            }

            return logFile.Id;
        }
Ejemplo n.º 10
0
        public Guid SaveFile(string fileName, byte[] file)
        {
            var softwareFile = new SoftwareFileTable()
            {
                Id = CombIdentityFactory.GenerateIdentity(),
                FileName = fileName,
                Binary = file
            };

            using (var context = new AppCampusContext())
            {
                context.SoftwareFiles.Add(softwareFile);

                context.SaveChanges();
            }

            return softwareFile.Id;
        }