public ActionResult CreateTicket(CreateTicketViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId   = User.Identity.GetUserId();
            var user     = GetUserById(userId);
            var type     = DbContext.TicketTypes.FirstOrDefault(t => t.Id == model.TypeId);
            var status   = DbContext.TicketStatuses.FirstOrDefault(s => s.Name == nameof(EnumTicketStatuses.Open).ToString());
            var priority = DbContext.TicketPriorities.FirstOrDefault(p => p.Id == model.PriorityId);
            var project  = DbContext.Projects.FirstOrDefault(p => p.Id == model.ProjectId);

            var newTicket = new Ticket();

            newTicket.Title             = model.Title;
            newTicket.Description       = model.Description;
            newTicket.DateCreated       = DateTime.Now;
            newTicket.DateUpdated       = null;
            newTicket.AssignedDeveloper = null;
            newTicket.Creator           = user;
            newTicket.Priority          = priority;
            newTicket.Status            = status;
            newTicket.Type    = type;
            newTicket.Project = project;
            DbContext.Tickets.Add(newTicket);
            DbContext.SaveChanges();

            return(RedirectToAction(nameof(BugController.ViewMyCreatedTickets), "Bug"));
        }
        public ActionResult CreateTicket()
        {
            var userId       = User.Identity.GetUserId();
            var userProjects = (from u in DbContext.Users
                                where u.Id == userId
                                select u.Projects).FirstOrDefault();

            var types = (from t in DbContext.TicketTypes
                         where t != null
                         select t).ToList();
            var priorities = (from p in DbContext.TicketPriorities
                              where p != null
                              select p).ToList();
            var statuses = (from s in DbContext.TicketStatuses
                            where s != null
                            select s).ToList();

            var model = new CreateTicketViewModel()
            {
                Projects   = userProjects,
                Priorities = priorities,
                Types      = types,
                Statuses   = statuses
            };

            return(View(model));
        }
Exemple #3
0
        public ActionResult Create(CreateTicketViewModel model)
        {
            if (this.CurrentUser.LocationId == null)
            {
                this.TempData[GlobalMessages.Danger] = "You must have company location to create tickets";
                return this.RedirectToAction("Index", "Home", new { area = string.Empty });
            }

            if (this.ModelState.IsValid && model != null)
            {
                var authorId = this.CurrentUser.Id;
                TicketType type = (TicketType)Enum.Parse(typeof(TicketType), model.Ticket.Type);
                TicketPriority priority = (TicketPriority)Enum.Parse(typeof(TicketPriority), model.Ticket.Priority);
                var ticketId = this.ticketService.Create(
                    model.Ticket.Title,
                    type,
                    TicketState.Open,
                    priority,
                    (int)this.CurrentUser.LocationId,
                    authorId).Id;

                this.ticketMessageService.Create(
                    model.Message.Content,
                    decimal.Zero,
                    ticketId,
                    authorId);

                return this.RedirectToAction("Details", "Ticket", new { area = string.Empty, id = ticketId });
            }

            return this.View(model);
        }
        public ActionResult Create(string ticketTag)
        {
            if (string.IsNullOrWhiteSpace(ticketTag))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            List <TicketStatus> availStatuses      = null;
            Project             parentProj         = db.Projects.First(p => p.TicketTag == ticketTag);
            ProjectWorkflow     parentProjWorkflow = parentProj.ActiveWorkflow;

            if (parentProjWorkflow.InitialTicketStatusId == null)
            {
                availStatuses = new List <TicketStatus>();
                foreach (TicketStatus ts in db.TicketStatuses.Where(ts => ts.MustBeAssigned == false && ts.IsStarted == false).ToList())
                {
                    availStatuses.Add(ts);
                }
            }

            var viewModel = new CreateTicketViewModel()
            {
                ParentProject        = parentProj,
                Reporter             = db.Users.Find(User.Identity.GetUserId()),
                PrioritySelections   = db.TicketPriorityTypes.ToDictionary(tp => tp.Name, tp => tp.Id),
                AvailableStatuses    = availStatuses,
                AvailableTicketTypes = db.TicketTypes.ToList()
            };

            return(View(viewModel));
        }
        public ActionResult CreateTicket(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var userId = User.Identity.GetUserId();
            //var userName = User.Identity.GetUserName();
            //string userName = DbContext.Users.ToList()[0].UserName;
            var ticket           = DbContext.TicketsDatabase.FirstOrDefault(p => p.Id == id);
            var ticketType       = DbContext.TicketsTypeDatabase.ToList();
            var ticketPriority   = DbContext.TicketsPriorityDatabase.ToList();
            var ticketAttachment = new CreateAttachmetsViewModel()
            {
            };
            var model = new CreateTicketViewModel
            {
                TicketType = ticketType.Select(p => new SelectListItem()
                {
                    Text  = p.Name,
                    Value = p.Id.ToString(),
                }).ToList(),
                TicketPriority = ticketPriority.Select(p => new SelectListItem()
                {
                    Text  = p.Name,
                    Value = p.Id.ToString(),
                }).ToList(),
                ProjectId = id.Value,
            };

            return(View(model));
        }
Exemple #6
0
        public ActionResult Create()
        {
            var newTicket = new CreateTicketViewModel();

            newTicket.Priority = Priority.Medium;
            return(View(newTicket));
        }
        public ActionResult Add(CreateTicketViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var ticket = Mapper.Map<Ticket>(model);
                ticket.AuthorId = this.CurrentUser.Id;

                if (model.UploadedImage != null)
                {
                    using (var memory = new MemoryStream())
                    {
                        model.UploadedImage.InputStream.CopyTo(memory);
                        var content = memory.GetBuffer();
                        ticket.Image = this.CreateImageModel(model.UploadedImage.FileName, content);
                    }
                }

                this.CurrentUser.Points++;
                this.Data.Tickets.Add(ticket);
                this.Data.SaveChanges();

                return this.RedirectToAction("All", "Tickets");
            }

            model.Categories = this.categoriesService.GetTicketCategories();
            return this.View(model);
        }
    public async Task Initialization()
    {
        CreateTicketViewModel viewModel = await viewModelTask;

        Assert.IsNotNull(viewModel);
        Assert.IsNotNull(viewModel.Ticket);
    }
Exemple #9
0
        public ActionResult Create(CreateTicketViewModel ticket)
        {
            if (ticket != null && ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();

                var newTicket = new Ticket
                {
                    AuthorId = userId,
                    CategoryId = ticket.Category,
                    Title = ticket.Title,
                    ScreenshotUrl = ticket.ScreenshotUrl,
                    Priority = ticket.Priority,
                    Description = ticket.Description,
                };

                this.Data.Tickets.Add(newTicket);
                this.Data.Authors.All().First(user => user.Id == userId).Points++;
                this.Data.SaveChanges();

                TempData["SuccessMessage"] = "Ticket added successfully!";
                return RedirectToAction("All");
            }

            ticket.AllCategories = GetCategoriesSelectList();
            ticket.AllPriorities = GetPrioritieSelectList();

            return View(ticket);
        }
        public ActionResult Add(CreateTicketViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var ticket = Mapper.Map <Ticket>(model);
                ticket.AuthorId = this.CurrentUser.Id;

                if (model.UploadedImage != null)
                {
                    using (var memory = new MemoryStream())
                    {
                        model.UploadedImage.InputStream.CopyTo(memory);
                        var content = memory.GetBuffer();
                        ticket.Image = this.CreateImageModel(model.UploadedImage.FileName, content);
                    }
                }

                this.CurrentUser.Points++;
                this.Data.Tickets.Add(ticket);
                this.Data.SaveChanges();

                return(this.RedirectToAction("All", "Tickets"));
            }

            model.Categories = this.categoriesService.GetTicketCategories();
            return(this.View(model));
        }
        public IActionResult Create(/*int accId, string problem*/ CreateTicketViewModel createTicket)
        {
            Ticket newTicket = mgr.AddTicket(/*accId*/ createTicket.AccId, /*problem*/ createTicket.Problem);

            cache.Remove("TicketList");
            return(RedirectToAction("Details", new { id = newTicket.TicketNumber }));
        }
Exemple #12
0
        public ActionResult Create(CreateTicketViewModel model)
        {
            if (this.ModelState.IsValid && model != null)
            {
                var            authorId = this.CurrentUser.Id;
                TicketType     type     = (TicketType)Enum.Parse(typeof(TicketType), model.Ticket.Type);
                TicketPriority priority = (TicketPriority)Enum.Parse(typeof(TicketPriority), model.Ticket.Priority);
                TicketState    state    = (TicketState)Enum.Parse(typeof(TicketState), model.Ticket.State);
                var            ticketId = this.ticketService.Create(
                    model.Ticket.Title,
                    type,
                    state,
                    priority,
                    int.Parse(model.Ticket.LocationId),
                    authorId).Id;

                this.ticketMessageService.Create(
                    model.Message.Content,
                    model.Message.PricingUnits,
                    ticketId,
                    authorId);

                return(this.RedirectToAction("Details", "Ticket", new { area = string.Empty, id = ticketId }));
            }

            return(this.View(model));
        }
Exemple #13
0
        public ActionResult Create(CreateTicketViewModel model)
        {
            if (this.ModelState.IsValid && model != null)
            {
                var authorId = this.CurrentUser.Id;
                TicketType type = (TicketType)Enum.Parse(typeof(TicketType), model.Ticket.Type);
                TicketPriority priority = (TicketPriority)Enum.Parse(typeof(TicketPriority), model.Ticket.Priority);
                TicketState state = (TicketState)Enum.Parse(typeof(TicketState), model.Ticket.State);
                var ticketId = this.ticketService.Create(
                    model.Ticket.Title,
                    type,
                    state,
                    priority,
                    int.Parse(model.Ticket.LocationId),
                    authorId).Id;

                this.ticketMessageService.Create(
                    model.Message.Content,
                    model.Message.PricingUnits,
                    ticketId,
                    authorId);

                return this.RedirectToAction("Details", "Ticket", new { area = string.Empty, id = ticketId });
            }

            return this.View(model);
        }
        public ActionResult Create(CreateTicketViewModel model)
        {
            model.OwnerId = GetCurrentUserId();
            var id = _ticketService.Init(model);

            return(RedirectToAction("Edit", new { id = id }));
        }
Exemple #15
0
        public ActionResult CreateTicket(Guid projectId)
        {
            CreateTicketViewModel model = new CreateTicketViewModel();

            if (Session["availableWorkers"] is null)
            {
                var availableWorkers = _repo.GetById(projectId).Workers;

                model.AvailaibleWorkers = availableWorkers.Select(x => {
                    return(new ApplicationUserViewModel()
                    {
                        Id = x.WorkerId.ToString(), Image = null, InProject = false, Name = x.UserName
                    });
                }).ToList();

                Session["availableWorkers"] = model.AvailaibleWorkers;
            }
            else
            {
                model.AvailaibleWorkers = (List <ApplicationUserViewModel>)Session["availableWorkers"];
            }

            model.ProjectId         = projectId;
            model.AvailaibleWorkers = model.AvailaibleWorkers.OrderBy(x => x.InProject == false).ToList();
            return(View(model));
        }
        public ActionResult Create(CreateTicketViewModel model)
        {
            if (this.CurrentUser.LocationId == null)
            {
                this.TempData[GlobalMessages.Danger] = "You must have company location to create tickets";
                return(this.RedirectToAction("Index", "Home", new { area = string.Empty }));
            }

            if (this.ModelState.IsValid && model != null)
            {
                var            authorId = this.CurrentUser.Id;
                TicketType     type     = (TicketType)Enum.Parse(typeof(TicketType), model.Ticket.Type);
                TicketPriority priority = (TicketPriority)Enum.Parse(typeof(TicketPriority), model.Ticket.Priority);
                var            ticketId = this.ticketService.Create(
                    model.Ticket.Title,
                    type,
                    TicketState.Open,
                    priority,
                    (int)this.CurrentUser.LocationId,
                    authorId).Id;

                this.ticketMessageService.Create(
                    model.Message.Content,
                    decimal.Zero,
                    ticketId,
                    authorId);

                return(this.RedirectToAction("Details", "Ticket", new { area = string.Empty, id = ticketId }));
            }

            return(this.View(model));
        }
        public ActionResult CreateTicket()
        {
            var model = new CreateTicketViewModel();

            model.Drawing = CurrentDrawing;

            return(View(model));
        }
Exemple #18
0
        public void Update(CreateTicketViewModel model)
        {
            var ticket = db.Tickets.FirstOrDefault(x => x.Id == model.Id);

            ticket.Title       = model.Title;
            ticket.Description = model.Description;
            db.SaveChanges();
        }
        public ActionResult Add()
        {
            var model = new CreateTicketViewModel()
            {
                Categories = this.categoriesService.GetTicketCategories()
            };

            return this.View(model);
        }
        public ActionResult Add()
        {
            var model = new CreateTicketViewModel()
            {
                Categories = this.categoriesService.GetTicketCategories()
            };

            return(this.View(model));
        }
        public ActionResult Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction(nameof(TicketsController.Tickets)));
            }

            var ticket = DbContext.TicketsDatabase.FirstOrDefault(p => p.Id == id);

            if (ticket == null)
            {
                return(RedirectToAction(nameof(TicketsController.Tickets)));
            }


            var userId         = User.Identity.GetUserId();
            var ticketType     = DbContext.TicketsTypeDatabase.ToList();
            var ticketPriority = DbContext.TicketsPriorityDatabase.ToList();
            var ticketStatus   = DbContext.TicketsStatusDatabase.ToList();

            if (!(User.IsInRole("Admin") || User.IsInRole("Project Manager")) && User.IsInRole("Submitter"))
            {
                ticketStatus.Clear();
            }
            var model = new CreateTicketViewModel
            {
                Title       = ticket.Title,
                Description = ticket.Description,
                AssignedTo  = ticket.AssignedTo,
                MediaUrl    = ticket.MediaUrl,
                PriorityId  = ticket.TicketPriorityId,
                TypeId      = ticket.TicketTypeId,
                StatusId    = ticket.TicketStatusId,
                TicketType  = ticketType.Select(p => new SelectListItem()
                {
                    Text     = p.Name,
                    Value    = p.Id.ToString(),
                    Selected = (ticket?.TicketTypeId ?? -1) == p.Id,
                }).ToList(),
                TicketPriority = ticketPriority.Select(p => new SelectListItem()
                {
                    Text     = p.Name,
                    Value    = p.Id.ToString(),
                    Selected = (ticket?.TicketPriorityId ?? -1) == p.Id,
                }).ToList(),
                TicketStatus = ticketStatus.Select(p => new SelectListItem()
                {
                    Text     = p.Name,
                    Value    = p.Id.ToString(),
                    Selected = (ticket?.TicketStatusId ?? -1) == p.Id,
                }).ToList(),
                ProjectId = id.Value,
            };

            return(View(model));
        }
Exemple #22
0
        public ActionResult Create()
        {
            var model = new CreateTicketViewModel
            {
                AllCategories = GetCategoriesSelectList(),
                AllPriorities = GetPrioritieSelectList()
            };

            return View(model);
        }
Exemple #23
0
 public ActionResult UpdateTicketBySubmitter(CreateTicketViewModel model)
 {
     if (ModelState.IsValid)
     {
         var userId = User.Identity.GetUserId();
         ticketLogic.updateTicket(model, userId);
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Error"));
 }
Exemple #24
0
 public IActionResult Create(CreateTicketViewModel ticketModel)
 {
     if (ModelState.IsValid)
     {
         var userId = userManager.GetUserId(User);
         ticketService.Create(ticketModel.Title, ticketModel.Message, userId);
         return(RedirectToAction("Home"));
     }
     return(View(ticketModel));
 }
        public async Task <IActionResult> CreateTicketAsync([FromBody] CreateTicketViewModel createTicketViewModel)
        {
            var createTicketDTO = _mapper.Map <CreateTicketDTO>(createTicketViewModel);

            var ticketDTO = await _ticketService.CreateTicketAsync(createTicketDTO);

            var ticketViewModel = _mapper.Map <TicketViewModel>(ticketDTO);

            return(Ok(ticketViewModel));
        }
        public ActionResult Create()
        {
            var model = new CreateTicketViewModel();

            userId           = User.Identity.GetUserId();
            model.Projects   = bugTrackerHelper.GetDropDownListUsersProjects(userId);
            model.Types      = bugTrackerHelper.GetDropDownListTypes();
            model.Priorities = bugTrackerHelper.GetDropDownListPriorities();

            return(View(model));
        }
Exemple #27
0
        public async Task <ActionResult> CreateTicket(CreateTicketViewModel model)
        {
            var project = _repo.GetById(model.ProjectId);

            project.CreateTicket(model.Name, model.Description, model.AvailaibleWorkers.First().Id);

            await _repo.Update(project);

            Session.Clear();

            return(RedirectToAction($"Details/{ model.ProjectId }"));
        }
        public ActionResult Edit(int id)
        {
            var ticket = Context
                         .Tickets
                         .FirstOrDefault(p => p.Id == id);

            var model = new CreateTicketViewModel();

            model.Title = ticket.Title;

            return(View(model));
        }
        public async Task <IActionResult> EditTicket(CreateTicketViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            ticketRepository.UpdateTicket(viewModel.Ticket);
            await ticketRepository.CommitAsync();

            return(RedirectToAction("Details", new { ticketId = viewModel.Ticket.Id }));
        }
Exemple #30
0
 public IActionResult CreateTicket([FromBody] CreateTicketViewModel createTicketViewModel)
 {
     try
     {
         _ticketService.CreateTicket(createTicketViewModel, CurrentUser.Id);
         return(Ok());
     }
     catch (System.Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public ActionResult Create()
        {
            var statuses = Context.TicketStatuses.ToList();

            var selectListStatuses =
                new SelectList(statuses, "Id", "Name");

            var model = new CreateTicketViewModel();

            model.AllStatuses = selectListStatuses;

            return(View(model));
        }
        public async Task <IActionResult> CreateNewTicket(CreateTicketViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            await ticketRepository.AddTicketAsync(viewModel.Ticket);

            await ticketRepository.CommitAsync();

            return(RedirectToAction("Index"));
        }
Exemple #33
0
        public void CreateTicket(CreateTicketViewModel model)
        {
            var ticket = new Ticket()
            {
                Combination = model.Combination,
                // Prize = model.Prize,
                Round  = model.Round,
                Status = model.Status,
                UserId = model.UserId
            };

            _ticketRepository.Create(ticket);
        }
        public ActionResult Create(int?id, CreateTicketViewModel model)
        {
            var userId = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                var projects = DbContext.Projects
                               .Where(p => p.Users.Any(m => m.Id == userId && p.Archive == false))
                               .Select(p => new { p.Name, p.Id }).ToList();

                var types    = DbContext.TicketTypes.ToList();
                var status   = DbContext.TicketStatus.ToList();
                var priority = DbContext.TicketPriorities.ToList();

                model.ProjectList  = new SelectList(projects, "Name", "Name");
                model.TypeList     = new SelectList(types, "Name", "Name");
                model.StatusList   = new SelectList(status, "Name", "Name");
                model.PriorityList = new SelectList(priority, "Name", "Name");
                return(View(model));
            }

            Ticket ticket;

            if (!id.HasValue)
            {
                ticket = new Ticket();
                DbContext.Tickets.Add(ticket);
            }
            else
            {
                ticket = DbContext.Tickets.FirstOrDefault(p => p.Id == id && p.Project.Archive == false);

                if (ticket == null)
                {
                    return(RedirectToAction(nameof(TicketController.Index)));
                }
            }

            ticket.Title          = model.Title;
            ticket.Description    = model.Description;
            ticket.DateCreated    = DateTime.Now;
            ticket.CreatedBy      = DbContext.Users.FirstOrDefault(p => p.Id == userId);
            ticket.TicketType     = DbContext.TicketTypes.FirstOrDefault(p => p.Name == model.TicketTypeName);
            ticket.TicketPriority = DbContext.TicketPriorities.FirstOrDefault(p => p.Name == model.TicketPriorityName);
            ticket.TicketStatus   = DbContext.TicketStatus.FirstOrDefault(p => p.Name == "Open");
            ticket.Project        = DbContext.Projects.FirstOrDefault(p => p.Name == model.ProjectName && p.Archive == false);

            DbContext.SaveChanges();

            return(RedirectToAction(nameof(TicketController.Index)));
        }
        public ActionResult Create(CreateTicketViewModel model, string returnUrl)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(model);
            }

            var newTicket = this.Mapper.Map<Ticket>(model);

            newTicket.CreatedOn = DateTime.UtcNow;
            newTicket.CreatorId = this.User.Identity.GetUserId();

            this.ticketsService.Add(newTicket);

            return this.RedirectToAction("Index", "Home", new { area = "" });
        }
        public ActionResult Create()
        {
            CreateTicketViewModel model = new CreateTicketViewModel();
            model.CategoryItems = Data.Categories.All().ToList().Select(x => new SelectListItem()
            {
                Value = x.Id.ToString(),
                Text = x.Name
            }).ToList();

            model.PriorityItems = Enum.GetValues(typeof(PriorityType)).Cast<PriorityType>().Select(v => new SelectListItem
            {
                Text = v.ToString(),
                Value = ((int)v).ToString()
            }).ToList();

            return View(model);
        }
        public ActionResult Create(CreateTicketViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                var ticket = new Ticket();
                ticket.AuthorId = userId;
                ticket.CategoryId = model.SelectedCategory;
                ticket.Title = model.Title;
                ticket.Priority = model.SelectedPriority;
                ticket.ScreenshotURL = model.ScreenshotUrl;
                ticket.Description = model.Description;
             
                Data.Tickets.Add(ticket);

                var user = Data.ApplicationUser.All().FirstOrDefault(x => x.Id == userId);
                if (user != null)
                {
                    user.Points++;
                }
                
                Data.SaveChanges();
            }

            //model = new TicketViewModel();

            //model.CategoryItems = Data.Categories.All().ToList().Select(x => new SelectListItem()
            //{
            //    Value = x.Id.ToString(),
            //    Text = x.Name
            //}).ToList();

            //model.PriorityItems = Enum.GetValues(typeof(PriorityType)).Cast<PriorityType>().Select(v => new SelectListItem
            //{
            //    Text = v.ToString(),
            //    Value = ((int)v).ToString()
            //}).ToList();

            return RedirectToAction("Create");
        }