Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var model = new TicketsViewModel();

            model.DepName = "Örebro Centralstation";
            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PacientTickets(string id, string returnUrl, string status, bool isError = false)
        {
            if (string.IsNullOrEmpty(id))
            {
                id = _userManager.GetUserId(User);
            }
            IQueryable <Ticket> source = _scheduleService.GetUserTickets(false, id)
                                         .Include(x => x.Schedule);

            if (User.IsInRole("Admin") || User.IsInRole("Doctor"))
            {
                source = source.Include(x => x.Pacient);
            }
            if (User.IsInRole("Admin") || User.IsInRole("Pacient"))
            {
                source = source.Include(x => x.Schedule.Doctor)
                         .Include(x => x.Schedule.Doctor.Cabinet);
            }
            TicketsViewModel ticketsViewModel = new TicketsViewModel();

            ticketsViewModel.userId  = id;
            ticketsViewModel.Tickets = await source.ToListAsync();

            ticketsViewModel.ReturnUrl     = returnUrl;
            ticketsViewModel.StatusMessage = status;
            ticketsViewModel.IsError       = isError;
            return(View("Tickets", ticketsViewModel));
        }
        // GET: Tickets

        public ActionResult Index()
        {
            var VM            = new TicketsViewModel();
            var currentUserId = User.Identity.GetUserId();

            VM.AllTickets.AddRange(db.Tickets.ToList());
            if (User.IsInRole("Sub"))
            {
                VM.SubTickets = VM.AllTickets.Where(t => t.OwnerUserId == currentUserId).ToList();
            }
            if (User.IsInRole("Devs"))
            {
                VM.DevTickets = VM.AllTickets.Where(t => t.AssignedToUserId == currentUserId).ToList();
            }
            if (User.IsInRole("Devs") || User.IsInRole("PM"))
            {
                var MyProjects = Projecthelper.ListUserProjects(currentUserId);
                foreach (var project in MyProjects)
                {
                    VM.ProjTickets.AddRange(project.Tickets);
                }
            }

            return(View(VM));
        }
        public ViewResult Browse()
        {
            var vm = new TicketsViewModel();

            LayoutHelper.FillLayoutModel(vm);

            return(this.View(vm));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuOptions"/> class.
 /// </summary>
 public Tickets()
 {
     InitializeComponent();
     this.viewModel = Resources["TicketsViewModel"] as TicketsViewModel;
     Navigator.SetSource(this, this.viewModel);
     Loaded     += new RoutedEventHandler(this.Page_Loaded);
     this.KeyUp += new KeyEventHandler(this.OnKeyUp);
 }
        public TicketsPage()
        {
            InitializeComponent();

            Binding        = new TicketsViewModel();
            BindingContext = Binding;

            System.Diagnostics.Debug.WriteLine("Number of items: " + Binding.Data.Count.ToString());
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Tickets(int eventId)
        {
            var model = new TicketsViewModel
            {
                Event      = await _service.GetEvent(eventId),
                TicketList = await _service.GetAllTicketsByEvent(eventId)
            };

            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult DisplayTickets(TicketsViewModel model)
        {
            TicketsDal       dal      = new TicketsDal();
            TicketsViewModel mvm      = new TicketsViewModel();
            List <Tickets>   ticketss = dal.TicketsList.ToList();

            mvm.Tickets     = new Tickets();
            mvm.TicketsList = ticketss;
            return(View(mvm));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Index()
        {
            var tickets = await _ticketClientService.GetTickets();

            var vm = new TicketsViewModel()
            {
                Tickets = tickets
            };

            return(View(vm));
        }
 private Ticket MapTicketViewModelIntoDataObject(TicketsViewModel viewModel, string callerId)
 {
     return(new Ticket
     {
         TicketIssuerUserId = callerId,
         Message = viewModel.Message,
         IsPending = true,
         CreatedDate = DateTime.Now,
         AddressedMessage = string.Empty,
         AddressedById = string.Empty
     });
 }
Ejemplo n.º 11
0
        // GET: Tickets
        public ActionResult Management()
        {
            ViewData["TicketManagement"] = "active";
            var viewModel = new TicketsViewModel()
            {
                MyTickets       = ticketsService.GetMyTickets(User.UserId),
                AssignedToMe    = ticketsService.GetAssignedTickets(User.UserId),
                OpenTickets     = ticketsService.GetOpenTickets(),
                AllTicketsPaged = User.IsAdministrator?  ticketsService.GetAllTickets() : ticketsService.GetAssignedTickets(User.UserId)
            };

            return(View(viewModel));
        }
Ejemplo n.º 12
0
        public AddTicketPage(TicketsViewModel vm)
        {
            _viewModel      = vm;
            BackgroundColor = Color.White;

            ToolbarItem save = new ToolbarItem
            {
                Text = "Save"
            };

            save.Clicked += Save_ClickedAsync;
            ToolbarItems.Add(save);
            FillLayout("Ticket Name");
        }
Ejemplo n.º 13
0
        public ActionResult Index()
        {
            var userId = User.Identity.GetUserId();
            var model  = new TicketsViewModel
            {
                subTickets  = db.Tickets.Where(t => t.OwnerUserId == userId).ToList(),
                devTickets  = db.Tickets.Where(t => t.AssignedToUserId == userId).ToList(),
                projTickets = db.Users.Find(userId).Projects.SelectMany(t => t.Tickets).ToList(),

                allTickets = db.Tickets.ToList()
            };

            return(View(model));
        }
Ejemplo n.º 14
0
        public ViewModelLocator()
        {
            try
            {
                var config = new ConfigurationBuilder();
                config.AddJsonFile("autofac.json");
                var module  = new ConfigurationModule(config.Build());
                var builder = new ContainerBuilder();
                builder.RegisterModule(module);
                Container = builder.Build();

                navigationService = Container.Resolve <INavigationService>();
                apiService        = Container.Resolve <IApiService>();
                messageService    = Container.Resolve <IMessageService>();

                appViewModel             = Container.Resolve <AppViewModel>();
                startPageViewModel       = Container.Resolve <StartPageViewModel>();
                signUpViewModel          = Container.Resolve <SignUpViewModel>();
                tripBoardViewModel       = Container.Resolve <TripBoardViewModel>();
                addNewTripViewModel      = Container.Resolve <AddNewTripViewModel>();
                addDestinationsViewModel = Container.Resolve <AddDestinationsViewModel>();
                addNewTripTaskViewModel  = Container.Resolve <AddNewTripTaskViewModel>();
                reviewTripViewModel      = Container.Resolve <ReviewTripViewModel>();
                tripTasksViewModel       = Container.Resolve <TripTasksViewModel>();
                destinationsViewModel    = Container.Resolve <DestinationsViewModel>();
                routeMapViewModel        = Container.Resolve <RouteMapViewModel>();
                ticketsViewModel         = Container.Resolve <TicketsViewModel>();
                checkTicketViewModel     = Container.Resolve <CheckTicketViewModel>();

                navigationService.Register <StartPageViewModel>(startPageViewModel);
                navigationService.Register <SignUpViewModel>(signUpViewModel);
                navigationService.Register <TripBoardViewModel>(tripBoardViewModel);
                navigationService.Register <AddNewTripViewModel>(addNewTripViewModel);
                navigationService.Register <AddDestinationsViewModel>(addDestinationsViewModel);
                navigationService.Register <AddNewTripTaskViewModel>(addNewTripTaskViewModel);
                navigationService.Register <ReviewTripViewModel>(reviewTripViewModel);
                navigationService.Register <TripTasksViewModel>(tripTasksViewModel);
                navigationService.Register <DestinationsViewModel>(destinationsViewModel);
                navigationService.Register <RouteMapViewModel>(routeMapViewModel);
                navigationService.Register <TicketsViewModel>(ticketsViewModel);
                navigationService.Register <CheckTicketViewModel>(checkTicketViewModel);

                navigationService.Navigate <StartPageViewModel>();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 15
0
        public IActionResult ListTickets()
        {
            var ticketsViewModel = new TicketsViewModel
            {
                Tickets = _context.Ticket
                          .Include(t => t.TicketType)
                          .Include(t => t.TicketStatus)
                          .Include(t => t.AssignedFE)
                          .Include(t => t.Order)
                          .Include(t => t.Location)
                          .ToList()
            };

            return(View(ticketsViewModel));
        }
Ejemplo n.º 16
0
 public ActionResult Create()
 {
     try
     {
         TicketsViewModel ticketsViewModel = new TicketsViewModel()
         {
             ListofCategory = _category.GetAllActiveSelectListItemCategory(),
             ListofPriority = _priority.GetAllPrioritySelectListItem()
         };
         return(View(ticketsViewModel));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 17
0
        public async Task <ActionResult> ClaimSeat(Guid roomId, Guid MovieRoomId, DateTime Playtime, Guid MovieId)
        {
            TicketsViewModel tickets = new TicketsViewModel();

            Room room = await _cinemaRepository.GetRoomsAsync(roomId);

            if (room == null)
            {
                return(NotFound());
            }
            tickets.MovieId     = MovieId;
            tickets.MovieRoomId = MovieRoomId;
            tickets.room        = room;
            tickets.Playtime    = Playtime;
            return(View(tickets));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Tickets(long projectId, eTicketType type = eTicketType.Undefined, eTicketState state = eTicketState.Undefined)
        {
            TicketsViewModel model = new TicketsViewModel();

            model.Projects        = _ticketService.GetProjects().ToList();
            model.SelectedProject = model.Projects.FirstOrDefault(ll => ll.Id == projectId);
            model.Tickets         = _ticketService.GetTicketsSmall(projectId, type, state).ToList();
            model.TicketType      = type;
            model.TicketState     = state;

            if (User.Identity.IsAuthenticated)
            {
                await _ticketService.SetUserSeenTicketFlag(model.Tickets, User.Identity.Name);
            }

            return(View(model));
        }
Ejemplo n.º 19
0
        public IActionResult ListTicketsSolved()
        {
            var ticketsViewModel = new TicketsViewModel()
            {
                Tickets = _context.Ticket
                          .Include(t => t.Creator)
                          .Include(t => t.FEAssigned)
                          .Include(t => t.Receiver)
                          .Include(t => t.Site)
                          .Include(t => t.TicketPriority)
                          .Include(t => t.TicketStatus)
                          .Include(t => t.TicketType).Where(t => t.TicketStatusId == 3)
                          .ToList()
            };

            return(View(ticketsViewModel));
        }
Ejemplo n.º 20
0
        public async Task <ActionResult> AssignUsers(TicketsViewModel model, int ticketId, Tickets tickets)
        {
            var ticket  = db.Tickets.Find(ticketId);
            var oldTic  = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);
            var userId  = User.Identity.GetUserId();
            var userid  = User.Identity.GetUserId();
            var changed = System.DateTime.Now;

            ticket.AssignedToUserId = model.SelectedUsers;
            ticket.Updated          = DateTimeOffset.Now;
            db.SaveChanges(); foreach (var user in model.SelectedUsers)
            {
                if (oldTic?.AssignedToUserId != ticket.AssignedToUserId)
                {
                    string oldAssignedToUserId = oldTic.AssignedToUserId;
                    string newAssignedToUser   = db.Users.Find(ticket.AssignedToUserId).DisplayName;

                    TicketHistories th6 = new TicketHistories
                    {
                        TicketId = ticket.Id,
                        Property = "AssignedToUserId",
                        OldValue = oldTic?.AssignedToUser.DisplayName,
                        NewValue = ticket.AssignedToUser.DisplayName,
                        Changed  = changed,
                        UserId   = userid
                    };
                    db.TicketHistories.Add(th6);
                    db.SaveChanges();
                }
            }
            ApplicationUser NotifyUser = db.Users.FirstOrDefault(u => u.Id.Equals(tickets.AssignedToUserId));

            //ApplicationUser NotifyUser = db.Users.Find(ticket.AssignedToUserId);


            if (NotifyUser != null /*|| !(await UserManager.IsEmailConfirmedAsync(user.Id))*/)
            {
                var callBackUrl = Url.Action("Details", "Tickets", new { id = tickets.Id }, protocol: Request.Url.Scheme);
                await UserManager.SendEmailAsync(NotifyUser.Id, "Ticket Update" + tickets.Id, "Good day, this is a notification that you have been assigned to this  <a href=\"" + callBackUrl + "\">ticket</a>.");
            }

            return(RedirectToAction("Index", "Projects", model));
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> SearchTickets(int idDepartureTown, int idArrivalTown, DateTime dateFrom)
        {
            try {
                var tickets = await dbContext.Ticket
                              .Include(arrival => arrival.TrainArrivalTownNavigation)
                              .Include(departure => departure.TrainDepartureTownNavigation)
                              .Include(type => type.SeatNavigation.WagonNavigation.WagonTypeNavigation)
                              .Include(train => train.SeatNavigation.WagonNavigation.TrainWagonNavigation.TrainNavigation)
                              .Where(x => x.TicketDate >= dateFrom && x.IdTrainDepartureTown == idDepartureTown && x.IdTrainArrivalTown == idArrivalTown)
                              .ToListAsync();

                var result = tickets
                             .GroupBy(x => new {
                    ArrivalTown   = x.TrainArrivalTownNavigation.TownName,
                    DepartureTown = x.TrainDepartureTownNavigation.TownName,
                    x.TicketDate,
                    x.SeatNavigation.WagonNavigation.TrainWagonNavigation.TrainNavigation.TrainName
                })
                             .Select(x => new {
                    x.Key.DepartureTown,
                    x.Key.ArrivalTown,
                    x.Key.TicketDate,
                    x.Key.TrainName
                }).ToList();

                var findTicketViewModel = new List <TicketsViewModel>();
                for (var i = 0; i < result.Count; i++)
                {
                    var item = new TicketsViewModel {
                        ArrivalTown   = result[i].ArrivalTown,
                        DepartureTown = result[i].DepartureTown,
                        DepartureTime = result[i].TicketDate,
                        TrainName     = result[i].TrainName
                    };
                    findTicketViewModel.Add(item);
                }
                ViewBag.ArrivalTowns   = new SelectList(dbContext.TrainArrivalTown.ToList(), "IdTrainArrivalTown", "TownName");
                ViewBag.DepartureTowns = new SelectList(dbContext.TrainDepartureTown.ToList(), "IdTrainDepartureTown", "TownName");
                return(View("Index", findTicketViewModel));
            } catch {
                return(NotFound());
            }
        }
Ejemplo n.º 22
0
        public async Task <IActionResult> Index()
        {
            var currentUserId = userManager.GetUserId(User);
            var userTickets   = await ticketsService.GetTicketsByUserId(currentUserId);

            var myTickets = new List <TicketView> {
            };

            foreach (var ticket in userTickets)
            {
                var ticketEvent = await eventsService.GetEventById(ticket.EventId);

                var ticketOrder = await ordersService.GetOrderByTicketIdAndStatuses(ticket.Id, OrderStatuses.WaitingForConfirmation, OrderStatuses.Confirmed, OrderStatuses.Completed);

                var orderUser = await userManager.FindByIdAsync(ticketOrder?.UserId);

                myTickets.Add(
                    new TicketView
                {
                    TicketId            = ticket.Id,
                    TicketPrice         = ticket.Price,
                    TicketStatus        = ticket.Status,
                    BuyerName           = orderUser?.UserName,
                    BuyerId             = orderUser?.Id,
                    OrderId             = ticketOrder?.Id,
                    EventName           = ticketEvent.Name,
                    EventId             = ticket.EventId,
                    EventDate           = ticketEvent.Date,
                    OrderTrackingNumber = ticketOrder?.TrackingNumber
                }
                    );
            }
            ;

            var model = new TicketsViewModel
            {
                Tickets = myTickets.ToArray()
            };

            return(View(model));
        }
Ejemplo n.º 23
0
        public ViewModelLocator()
        {
            myNavigationService = new MyNavigationService();

            appViewModel          = new AppViewModel(myNavigationService);
            logInViewModel        = new LogInViewModel(myNavigationService);
            menyuViewModel        = new MenyuViewModel(myNavigationService);
            tripsViewModel        = new TripsViewModel(myNavigationService);
            registrationViewModel = new RegistrationViewModel(myNavigationService);
            weatherViewModel      = new WeatherViewModel(myNavigationService);
            ticketsPDFViewModel   = new TicketsPDFViewModel(myNavigationService);
            citiesViewModel       = new CitiesViewModel(myNavigationService);
            introViewModel        = new IntroViewModel(myNavigationService);
            mapViewModel          = new MapViewModel(myNavigationService);
            searchInfoViewModel   = new SearchInfoViewModel(myNavigationService);
            ticketsViewModel      = new TicketsViewModel(myNavigationService);

            myNavigationService.Register <LogInViewModel>(logInViewModel);
            myNavigationService.Register <MenyuViewModel>(menyuViewModel);
            myNavigationService.Register <TripsViewModel>(tripsViewModel);
            myNavigationService.Register <RegistrationViewModel>(registrationViewModel);
            myNavigationService.Register <WeatherViewModel>(weatherViewModel);
            myNavigationService.Register <TicketsPDFViewModel>(ticketsPDFViewModel);
            myNavigationService.Register <CitiesViewModel>(citiesViewModel);
            myNavigationService.Register <IntroViewModel>(introViewModel);
            myNavigationService.Register <MapViewModel>(mapViewModel);
            myNavigationService.Register <SearchInfoViewModel>(searchInfoViewModel);
            myNavigationService.Register <TicketsViewModel>(ticketsViewModel);

            //myNavigationService.Register("LogIn", logInViewModel);
            //myNavigationService.Register("Menyu", menyuViewModel);
            //myNavigationService.Register("Trips", tripsViewModel);
            //myNavigationService.Register("Registration", registrationViewModel);

            //myNavigationService.Navigate<LogInViewModel>();
            myNavigationService.Navigate <IntroViewModel>();
            //myNavigationService.Navigate<TicketsPDFViewModel>();
            //myNavigationService.Navigate<TripsViewModel>();

            //myNavigationService.Navigate("LogIn");
        }
        public async Task <IActionResult> AddTicket([FromBody] TicketsViewModel ticketViewModel)
        {
            var callerId = GetCallerId();

            if (string.IsNullOrEmpty(callerId))
            {
                return(new BadRequestObjectResult(new
                {
                    Message = "You must be logged in to report!"
                }));
            }
            var result = await _ticketsRepository.CreateTicket(
                MapTicketViewModelIntoDataObject(ticketViewModel, callerId),
                callerId);

            return(new OkObjectResult(new
            {
                Message = "Report added1",
                result
            }));
        }
Ejemplo n.º 25
0
        // GET: Tickets/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var ticket = await _context.Tickets
                         .Include(t => t.Contact)
                         .Include(t => t.Contract)
                         .ThenInclude(t => t.Account)
                         .Include(t => t.TicketImpact)
                         .Include(t => t.TicketType)
                         .Include(t => t.TicketUrgency)
                         .FirstOrDefaultAsync(m => m.Id == id);

            if (ticket == null)
            {
                return(NotFound());
            }

            var assignedToUsername = await _userContext.Users
                                     .FirstOrDefaultAsync(u => u.Id == ticket.AssignedTo);

            var createdByUsername = await _userContext.Users
                                    .FirstOrDefaultAsync(u => u.Id == ticket.CreatedBy);

            var ticketsViewModel = new TicketsViewModel
            {
                Ticket             = ticket,
                AssignedToUserName = assignedToUsername.UserName,
                CreatedByUserName  = createdByUsername.UserName,
                Account            = ticket.Contract.Account.Name
            };


            return(View(ticketsViewModel));
        }
Ejemplo n.º 26
0
        public async Task <IHttpActionResult> GetTickets(HttpRequestMessage request, [FromBody]  TicketsViewModel ticketsViewModel)
        {
            IHttpActionResult response = null;

            try
            {
                TicketsViewModel result   = new TicketsViewModel();
                UserIdentityInfo userinfo = UserHelper.GetUserInfo(this);
                if (userinfo != null)
                {
                    int    currentPageNumber = ticketsViewModel.CurrentPageNumber;
                    int    pageSize          = ticketsViewModel.PageSize;
                    string sortExpression    = ticketsViewModel.SortExpression;
                    string sortDirection     = ticketsViewModel.SortDirection;
                    int    totalRows;

                    //if the OrganizationID comes with the request, than it is a Company admin in Customer view, else search with the current logged in OrganizationID
                    Guid organizationID = (ticketsViewModel.OrganizationID == null || ticketsViewModel.OrganizationID == default(Guid)) ? userinfo.OrganizationID : ticketsViewModel.OrganizationID.Value;

                    IEnumerable <Ticket> ticketlist = _ticketDataService.GetTickets(organizationID, ticketsViewModel.AccountNumber, ticketsViewModel.AccountName,
                                                                                    ticketsViewModel.TicketNumber, ticketsViewModel.DeliveryDate, ticketsViewModel.InvoiceNumber,
                                                                                    currentPageNumber, pageSize, sortExpression, sortDirection, out totalRows);


                    var ticketViewModelList = ticketlist.Select(ticket => (TicketViewModel)ticket);
                    result.Tickets   = ticketViewModelList.ToList();
                    result.TotalRows = totalRows;
                }
                response = ResponseMessage(Request.CreateResponse <TicketsViewModel>(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                string message = UserHelper.ErrorHandler(ex);
                response = BadRequest(message);
            }
            return(response);
        }
Ejemplo n.º 27
0
        public async Task <ActionResult> Index(TicketsViewModel newTicket)
        {
            if (ModelState.IsValid)
            {
                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync("http://localhost:51901/api/travels/{destName}" + newTicket.DestName);

                    if (response.IsSuccessStatusCode)
                    {
                        var content = await response.Content.ReadAsStringAsync();

                        var json   = JObject.Parse(content);
                        var ticket = new TicketsViewModel()
                        {
                            DepName      = json["DepName"].Value <string>(),
                            DepTime      = (DateTime)json["DepTime"],
                            DestName     = json["DestName"].Value <string>(),
                            DestTime     = (DateTime)json["DestTime"],
                            DestLon      = json["DestLon"].Value <string>(),
                            DestLat      = json["DestLat"].Value <string>(),
                            Celsius      = json["Celsius"].Value <decimal>(),
                            ForecastName = json["ForecastName"].Value <string>()
                        };
                        return(View(ticket));
                    }
                }
            }
            else
            {
                TempData["Message"] = "Destination can not be empty.";
                TempData["Type"]    = "alert-danger";
                return(RedirectToAction("Index"));
            }
            return(HttpNotFound());
        }
Ejemplo n.º 28
0
        //Building the Tickets page
        public TicketsPage(INavigation navigation, TicketsViewModel vm)
        {
            _viewModel = vm;
            _viewModel.PropertyChanged += _viewModel_PropertyChanged;
            this.navigation             = navigation;

            Title           = "Tickets";
            BackgroundColor = Color.White;

            DependencyService.Get <IStatusBar> ().ShowStatusBar();

            //Listview displaying the available tickets
            listView = new ListView();
            listView.ItemTemplate = new DataTemplate(typeof(CustomImageCell));
            listView.ItemTemplate.SetBinding(ImageCell.TextProperty, "Name");
            listView.ItemTemplate.SetBinding(ImageCell.DetailProperty, "Detail");
            listView.ItemTemplate.SetBinding(ImageCell.ImageSourceProperty, "Image");
            listView.ItemTapped   += ListView_ItemTapped;
            listView.ItemSelected += (sender, e) =>
            {
                ((ListView)sender).SelectedItem = null;
            };

            //Controller for adding tickets
            ToolbarItem addTicket = new ToolbarItem
            {
                Text = "Add Ticket",
                Icon = Device.RuntimePlatform == Device.Android ? "add_ic" : ""
            };

            addTicket.Clicked += AddTicket_ClickedAsync;

            ToolbarItems.Add(addTicket);
            Content = listView;
            RefreshList(null);
        }
Ejemplo n.º 29
0
        public TicketsViewModelTests()
        {
            areas = new List <AreaViewModel>
            {
                new AreaViewModel
                {
                    Id          = 1,
                    Name        = "Area1",
                    Description = "Description1",
                    Selected    = false
                },
                new AreaViewModel
                {
                    Id          = 2,
                    Name        = "Area2",
                    Description = "Description2",
                    Selected    = false
                },
                new AreaViewModel
                {
                    Id          = 3,
                    Name        = "Area3",
                    Description = "Description3",
                    Selected    = true
                }
            };

            accessToken = "AccessToken";

            tokenServiceMock = new Mock <ITokenService>();
            tokenServiceMock.Setup(ts => ts.RefreshTokenAsync());

            localTokenServiceMock = new Mock <ILocalTokenService>();
            localTokenServiceMock
            .Setup(lts => lts.GetAccessTokenAsync())
            .ReturnsAsync(accessToken);

            ticketTypes = new List <TicketType>
            {
                new TicketType
                {
                    Id            = 1,
                    Name          = "TickeType",
                    Coefficient   = 1,
                    DurationHours = 10,
                    Amount        = 100
                }
            };

            areasDto = new List <AreaDto>
            {
                new AreaDto
                {
                    Id          = 1,
                    Name        = "Area1",
                    Description = "Description1"
                },
                new AreaDto
                {
                    Id          = 2,
                    Name        = "Area2",
                    Description = "Description2"
                },
                new AreaDto
                {
                    Id          = 3,
                    Name        = "Area3",
                    Description = "Description3"
                }
            };

            ticketsServiceMock = new Mock <ITicketsService>();
            ticketsServiceMock
            .Setup(ts => ts.GetTicketTypesAsync(It.IsAny <string>()))
            .ReturnsAsync(ticketTypes);

            ticketsServiceMock
            .Setup(ts => ts.GetAreasDtoAsync(It.IsAny <string>()))
            .ReturnsAsync(areasDto);

            getTicketPriceResponseDto = new GetTicketPriceResponseDto {
                TotalPrice = 100
            };

            ticketsServiceMock
            .Setup(ts => ts.RequestGetTicketPriceAsync(It.IsAny <IEnumerable <int> >(), It.IsAny <int>()))
            .ReturnsAsync(getTicketPriceResponseDto);

            dialogServiceMock = new Mock <IPageDialogService>();

            ticketsViewModel = new TicketsViewModel(null, localTokenServiceMock.Object, dialogServiceMock.Object, ticketsServiceMock.Object, tokenServiceMock.Object);
        }
Ejemplo n.º 30
0
        public ActionResult Create(TicketsViewModel ticketsViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (ticketsViewModel.HiddenUserId == null)
                    {
                        ticketsViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                        ticketsViewModel.ListofPriority = _priority.GetAllPrioritySelectListItem();
                        ticketsViewModel.Message        = string.Empty;
                        ModelState.Remove("Message");
                        TempData["ErrorMessageTicket"] = "Name is AutoComplete field Don't Enter Name Choose.";
                        return(View(ticketsViewModel));
                    }

                    var file          = Request.Files;
                    var generate      = new GenerateTicketNo();
                    var applicationNo =
                        generate.ApplicationNo(_category.GetCategoryCodeByCategoryId(ticketsViewModel.CategoryId));

                    var tickets = AutoMapper.Mapper.Map <Tickets>(ticketsViewModel);
                    tickets.TicketId       = 0;
                    tickets.CreatedDate    = DateTime.Now;
                    tickets.TrackingId     = applicationNo;
                    tickets.StatusAssigned = false;
                    tickets.InternalUserId = Convert.ToInt64(_sessionHandler.UserId);

                    var message       = AppendSignature(ticketsViewModel.Message);
                    var ticketDetails = new TicketDetails()
                    {
                        Subject         = ticketsViewModel.Subject,
                        Message         = message,
                        TicketDetailsId = 0
                    };

                    var attachments       = new Attachments();
                    var attachmentdetails = new AttachmentDetails();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachments = new List <Attachments>();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachmentdetails = new List <AttachmentDetails>();

                    for (int i = 0; i <= file.Count - 1; i++)
                    {
                        if (file[i] != null && file[i].ContentLength > 0)
                        {
                            string extension = Path.GetExtension(file[i].FileName);
                            attachments.UserId         = Convert.ToInt64(_sessionHandler.UserId);
                            attachments.AttachmentName = file[i].FileName;
                            attachments.AttachmentType = extension;
                            attachments.CreatedDate    = DateTime.Now;
                            var inputStream = file[i].InputStream;
                            if (inputStream != null)
                            {
                                using (var binaryReader = new BinaryReader(inputStream))
                                {
                                    byte[] fileSize = binaryReader.ReadBytes(count: file[i].ContentLength);
                                    attachmentdetails.AttachmentBytes = fileSize;
                                }
                            }

                            listofattachments.Add(attachments);
                            listofattachmentdetails.Add(attachmentdetails);
                        }
                    }

                    var ticketId = _tickets.AddTickets(ticketsViewModel.HiddenUserId, tickets, ticketDetails, listofattachments, listofattachmentdetails);

                    if (ticketId != -1)
                    {
                        TempData["MessageTicket"] = applicationNo + ' ' + CommonMessages.TicketSuccessMessages;

                        TicketHistoryHelper ticketHistoryHelper = new TicketHistoryHelper();
                        var ticketHistory = new TicketHistory();
                        ticketHistory.UserId       = Convert.ToInt32(_sessionHandler.UserId);
                        ticketHistory.Message      = ticketHistoryHelper.CreateMessage(tickets.PriorityId, tickets.CategoryId);
                        ticketHistory.CategoryId   = tickets.CategoryId;
                        ticketHistory.PriorityId   = tickets.PriorityId;
                        ticketHistory.StatusId     = Convert.ToInt16(StatusMain.Status.Open);
                        ticketHistory.ProcessDate  = DateTime.Now;
                        ticketHistory.TicketId     = ticketId;
                        ticketHistory.ActivitiesId = Convert.ToInt16(StatusMain.Activities.Created);
                        _ticketHistory.TicketHistory(ticketHistory);
                    }
                    else
                    {
                        TempData["ErrorMessageTicket"] = CommonMessages.TicketErrorMessages;
                    }

                    return(RedirectToAction("Create", "TicketHOD"));
                }
                else
                {
                    ticketsViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                    ticketsViewModel.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    return(View(ticketsViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }