public void UpdatePriority(Ticket ticket)
 {
     using (var context = new TicketingContext())
     {
         var dbEntity = context.Tickets.First(t => t.Id == ticket.Id);
         dbEntity.Priority = (int)ticket.Priority;
         context.SaveChanges();
     }
 }
        public Entities.Ticket GetBy(Guid id)
        {
            Entities.Ticket result = null;
            using (var context = new TicketingContext())
            {
                var dbEntity = context.Tickets.Include(t => t.Images).FirstOrDefault(t => t.Id == id);
                if (dbEntity != null)
                {
                    result = dbEntity.ToCore();
                }
            }

            return(result);
        }
        public Guid Create(Entities.Ticket ticket)
        {
            var result = Guid.Empty;

            using (var context = new TicketingContext())
            {
                var dbEntity = ticket.FromCore();
                context.Tickets.Add(dbEntity);
                context.SaveChanges();

                result = dbEntity.Id;
            }

            return(result);
        }
        public Guid AttachVideo(Entities.Ticket ticket, Entities.Video video)
        {
            var result = Guid.Empty;

            using (var context = new TicketingContext())
            {
                var dbEntity = video.FromCore();
                dbEntity.TicketId = ticket.Id;
                context.Videos.Add(dbEntity);
                context.SaveChanges();

                result   = dbEntity.Id;
                video.Id = dbEntity.Id;
            }

            _storage.StoreVideo(video);

            return(result);
        }
        public Guid AttachImage(Entities.Ticket ticket, Entities.Image image)
        {
            var result = Guid.Empty;

            using (var context = new TicketingContext())
            {
                var dbEntity = image.FromCore();
                dbEntity.TicketId = ticket.Id;
                context.Images.Add(dbEntity);
                context.SaveChanges();

                result   = dbEntity.Id;
                image.Id = dbEntity.Id;
            }

            _storage.StoreImage(image);

            return(result);
        }