public ActionResult Create(int id)
        {
            ViewBag.TicketId = id;
            AttachmentFormViewModel viewModel = new AttachmentFormViewModel()
            {
                TicketId = id,
            };

            return(View(viewModel));
        }
        public ActionResult Edit(AttachmentFormViewModel viewModel)
        {
            User loggedInUser = userHelper.GetUserFromId(User.Identity.GetUserId());

            if (ticketHelper.isUserExistInTicket(loggedInUser.Id, viewModel.TicketId))
            {
                var attachmentInDb = db.TicketAttachments.Find(viewModel.Id);
                attachmentInDb.Description = viewModel.Description;
                attachmentInDb.FilePath    = ticketHelper.saveFile(viewModel.File);
                db.SaveChanges();
            }
            ;
            return(RedirectToAction("List", new { id = viewModel.TicketId }));
        }
        public ActionResult Create(AttachmentFormViewModel viewModel)
        {
            User loggedInUser = userHelper.GetUserFromId(User.Identity.GetUserId());

            if (ticketHelper.isUserExistInTicket(loggedInUser.Id, viewModel.TicketId))
            {
                TicketAttachments attachments = new TicketAttachments
                {
                    TicketId    = viewModel.TicketId,
                    UserId      = User.Identity.GetUserId(),
                    FilePath    = ticketHelper.saveFile(viewModel.File),
                    Description = viewModel.Description,
                    Created     = DateTime.Now,
                };
                db.TicketAttachments.Add(attachments);
                db.SaveChanges();
            }
            return(RedirectToAction("List", new { id = viewModel.TicketId }));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TicketAttachments ticketAttachments = db.TicketAttachments.Find(id);

            if (ticketAttachments == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new AttachmentFormViewModel()
            {
                Id          = ticketAttachments.Id,
                TicketId    = ticketAttachments.TicketId,
                Description = ticketAttachments.Description,
            };

            return(View(viewModel));
        }