/// <summary>
        /// Returns page with attachment
        /// </summary>
        /// <param name="id">ID of attachment</param>
        /// <returns></returns>
        public IActionResult ViewAttachment(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            TicketAttachment img = dbContext.TicketAttachments.Where(ta => ta.Id == id).Include(a => a.ApplicationUser).Include(a => a.Ticket).SingleOrDefault();

            if (img == null)
            {
                return(NotFound());
            }
            string imageBase64Data = Convert.ToBase64String(img.Image);
            string imageDataURL    = string.Format("data:image/jpg;base64,{0}", imageBase64Data);

            ViewBag.UserName     = img.ApplicationUser.UserName;
            ViewBag.TicketName   = img.Ticket.Title;
            ViewBag.ImageDataUrl = imageDataURL;
            return(View());
        }
        public async Task <IActionResult> CreateAttachment(int id)
        {
            var user = await userManager.GetUserAsync(HttpContext.User);

            Ticket ticket = dbContext.Tickets.Find(id);

            foreach (var file in Request.Form.Files)
            {
                TicketAttachment attachment = new TicketAttachment();
                attachment.ApplicationUser = user;
                attachment.Ticket          = ticket;
                attachment.Name            = file.FileName;

                MemoryStream ms = new MemoryStream();
                file.CopyTo(ms);
                attachment.Image = ms.ToArray();

                dbContext.TicketAttachments.Add(attachment);
            }
            dbContext.SaveChanges();
            return(RedirectToAction("Details", new { id }));
        }