public AddTicketPage() { this.InitializeComponent(); _viewModel = new AddTicketViewModel(); DataContext = _viewModel; }
public ActionResult Add(AddTicketViewModel ticket) { if (ticket != null && ModelState.IsValid) { var dbTicket = Mapper.Map <Ticket>(ticket); dbTicket.Author = this.UserProfile; if (ticket.UploadedImage != null) { using (var memory = new MemoryStream()) { ticket.UploadedImage.InputStream.CopyTo(memory); var content = memory.GetBuffer(); dbTicket.Image = new Image { Content = content, FileExtension = ticket.UploadedImage.FileName.Split(new[] { '.' }).Last() }; } } this.Data.Tickets.Add(dbTicket); this.Data.SaveChanges(); return(RedirectToAction("All", "Tickets")); } ticket.Categories = this.populator.GetCategories(); return(View(ticket)); }
public ActionResult Add(AddTicketViewModel ticket) { if (ticket != null && ModelState.IsValid) { var dbTicket = Mapper.Map<Ticket>(ticket); dbTicket.Author = this.UserProfile; if (ticket.UploadedImage != null) { using (var memory = new MemoryStream()) { ticket.UploadedImage.InputStream.CopyTo(memory); var content = memory.GetBuffer(); dbTicket.Image = new Image { Content = content, FileExtension = ticket.UploadedImage.FileName.Split(new[] { '.' }).Last() }; } } this.Data.Tickets.Add(dbTicket); this.Data.SaveChanges(); return RedirectToAction("All", "Tickets"); } ticket.Categories = this.populator.GetCategories(); return View(ticket); }
// GET: Tickets/AddTicket public async Task <IActionResult> AddTicketAsync() { var model = new AddTicketViewModel(); if (User.IsInRole("Developer") || User.IsInRole("Admin")) { ViewData["Companies"] = new SelectList(_context.Companies, "Id", "CompanyName"); var customers = await userManager.GetUsersInRoleAsync("Customer"); confirmedCustomers = customers.Where(a => a.EmailConfirmed == true); ViewData["CreatedBy"] = new SelectList(confirmedCustomers, "Id", "Email").OrderBy(m => m.Text); ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Name"); } else if (User.IsInRole("Customer")) { loggedInUser = await userManager.GetUserAsync(User); ViewData["ProjectId"] = new SelectList(_context.Projects.Where(g => g.CompanyId == loggedInUser.CompanyId), "Id", "Name"); } return(View(model)); }
public async Task <IActionResult> AddTicket([FromBody] AddTicketViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var registro = await _context.Registros .FirstOrDefaultAsync(u => u.hojaidhoja == model.idhoja && u.grupo == model.grupo && u.atribuible.atribcorto == "TI"); registro.idticket = model.idticket; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { // Guardar Excepción return(BadRequest()); } return(Ok()); }
public ActionResult AddTicket() { TempData["Title"] = "Add Ticket"; AddTicketViewModel m = new AddTicketViewModel(); return(View(m)); }
public IActionResult Edit(int?id) { var ticket = _repo.GetTicket(id); if (ticket == null) { return(Redirect("/Tickets/Index")); } var projects = _repo.GetAllProjects(); var developers = _repo.GetAllUsers(); var ticketViewModel = new AddTicketViewModel(projects, developers) { Title = ticket.Title, Description = ticket.Description, CreatedDate = ticket.CreatedDate, TicketStatus = ticket.TicketStatus, TicketPriority = ticket.TicketPriority, Type = ticket.Type, CreatedBy = ticket.CreatedBy, ProjectID = ticket.ProjectID, AssignedToId = ticket.AssignedToId }; return(View(ticketViewModel)); }
public async Task <IActionResult> CreateAsync(AddTicketViewModel ticketViewModel) { if (ModelState.IsValid) { var ticketProject = _repo.GetProject(ticketViewModel.ProjectID); var assignedUser = await _repo.FindUserByIdAsync(ticketViewModel.AssignedToId); var currentUser = await _repo.GetCurrentUser(User); // Map the ticket to the ticketViewModel //TODO - use AutoMapper when refactoring var ticket = new Ticket { Title = ticketViewModel.Title, Description = ticketViewModel.Description, TicketStatus = ticketViewModel.TicketStatus, TicketPriority = ticketViewModel.TicketPriority, Type = ticketViewModel.Type, ParentProject = ticketProject, AssignedTo = assignedUser, CreatedBy = $"{currentUser.FirstName} {currentUser.LastName}" }; _repo.CreateNewTicket(ticket); return(Redirect("/Tickets")); } return(View(ticketViewModel)); }
public ViewModelLocator() { ConfigurationBuilder config = new ConfigurationBuilder(); config.AddJsonFile("autofac.json"); ConfigurationModule module = new ConfigurationModule(config.Build()); ContainerBuilder builder = new ContainerBuilder(); builder.RegisterModule(module); Container = builder.Build(); navigationService = Container.Resolve <INavigationService>(); addTripViewModel = Container.Resolve <AddEditTripViewModel>(); addTicketViewModel = Container.Resolve <AddTicketViewModel>(); cityViewModel = Container.Resolve <CityViewModel>(); mainWindowViewModel = Container.Resolve <MainWindowViewModel>(); menuViewModel = Container.Resolve <MenuViewModel>(); routeMapViewModel = Container.Resolve <RouteMapViewModel>(); showTicketViewModel = Container.Resolve <ShowTicketViewModel>(); tripListViewModel = Container.Resolve <TripListViewModel>(); ticketsViewModel = Container.Resolve <TicketListViewModel>(); navigationService.Register <AddEditTripViewModel>(addTripViewModel); navigationService.Register <AddTicketViewModel>(addTicketViewModel); navigationService.Register <CityViewModel>(cityViewModel); navigationService.Register <MenuViewModel>(menuViewModel); navigationService.Register <RouteMapViewModel>(routeMapViewModel); navigationService.Register <ShowTicketViewModel>(showTicketViewModel); navigationService.Register <TicketListViewModel>(ticketsViewModel); navigationService.Register <TripListViewModel>(tripListViewModel); navigationService.Navigate <TripListViewModel>(); }
public AddTicket() { InitializeComponent(); DataContext = new AddTicketViewModel() { Window = this }; }
public ActionResult EditTicket(int id) { AddTicketViewModel m = new AddTicketViewModel(); ViewBag.TktNatures = m.TktNatures; ViewBag.Modules = m.TktModules; return(View(m.MyTickets.Where(t => t.TicketID == id).FirstOrDefault())); }
public IActionResult Create() { var projects = _repo.GetAllProjects(); var developers = _repo.GetAllUsers(); var ticketViewModel = new AddTicketViewModel(projects, developers); return(View(ticketViewModel)); }
public ActionResult AddTicket() { var model = new AddTicketViewModel { Categories = unitOfWork.Categories.GetListCategories() }; return View(model); }
public ActionResult Add() { var addTicketViewModel = new AddTicketViewModel { Categories = this.populator.GetCategories() }; return(View(addTicketViewModel)); }
public ActionResult Add() { var addTicketViewModel = new AddTicketViewModel { Categories = this.populator.GetCategories() }; return View(addTicketViewModel); }
public ActionResult EditTicket(Ticket tkt) { string msg = ""; Tkt.UpdateTicket(tkt, out msg); ViewBag.msg = msg; AddTicketViewModel m = new AddTicketViewModel(); return(RedirectToAction("AddTicket", m)); }
public ActionResult AddTicket(Ticket tkt) { string msg = ""; Tkt.AddNewTicket(tkt, out msg); ViewBag.msg = msg; TempData["Title"] = "Add Ticket"; AddTicketViewModel m = new AddTicketViewModel(); return(View(m)); }
public ActionResult Add(AddTicketViewModel ticket) { if (ticket != null && ModelState.IsValid) { this.detailsServices.AddTicketToDB(ticket); return(RedirectToAction("All", "Tickets")); } ticket.Categories = this.detailsServices.GetCategories(); return(View(ticket)); }
public AddTicketViewModel GetTicketViewModel(int flightId, int rateId) { AddTicketViewModel result = new AddTicketViewModel(); result.FlightId = flightId; result.RateId = rateId; result.Ages = EnumExtensions.GetEnumList("Age"); result.Genders = EnumExtensions.GetEnumList("Gender"); result.Documents = EnumExtensions.GetEnumList("Document"); result.TicketInfo = (from f in db.Flights join fr in db.Flight_Rates on f.Id equals fr.FlightId join r in db.Rates on fr.RateId equals r.Id join a in db.Aircrafts on f.AircraftId equals a.Id join am in db.AircraftModels on a.ModelId equals am.Id join airl in db.Airlines on f.AirlineId equals airl.Id join wp1 in db.Waypoints on f.StartingPointId equals wp1.Id join wp2 in db.Waypoints on f.TermitationPointId equals wp2.Id where f.Id == flightId & r.Id == rateId select new FlightByFilter { FlightId = f.Id, RateId = r.Id, Aircraft = a, AircraftModel = am.Model, AirlineId = airl.Id, AirlineName = airl.Name, Name = r.Name, Cost = r.Cost, BaggageDimensions = r.BaggageDimensions, Cancellble = r.Cancellble, Returnable = r.Returnable, ServiceClass = r.ServiceClass, StartingPoint = wp1, TermitationPoint = wp2, }).First(); result.Rates = (from f in db.Flights join fr in db.Flight_Rates on f.Id equals fr.FlightId join r in db.Rates on fr.RateId equals r.Id where fr.FlightId == flightId select new Rate { Id = r.Id, Name = r.Name, Cost = r.Cost, BaggageDimensions = r.BaggageDimensions, Cancellble = r.Cancellble, Returnable = r.Returnable, ServiceClass = r.ServiceClass }).ToList(); return(result); }
public IActionResult Add(AddTicketViewModel model) { if (!this.ModelState.IsValid) { this.ViewData[GlobalConstants.Statuses] = this.statusesService.GetAllStatuses(); return(this.View(model)); } var userId = this.userManager.GetUserId(User); this.ticketsService.AddTicket(model.TicketKey, model.Description, model.TicketLabel, userId, model.Volume ?? 0, model.DispatchDate, model.StatusId, model.FirstCheck, model.SecondCheck); return(this.RedirectToAction(nameof(Index))); }
public IActionResult Edit(int id) { Ticket theTicket = context.Tickets.Find(id); AddTicketViewModel ticket = new AddTicketViewModel { Id = theTicket.Id, Description = theTicket.Description, Picture1 = theTicket.Picture1, Picture2 = theTicket.Picture2, Picture3 = theTicket.Picture3 }; return(View(ticket)); }
public ActionResult EnterNew(AddTicketViewModel model) { Ticket ticket = new Ticket { Name = model.Name, Numbers = new int[6] { model.Numbers1, model.Numbers2, model.Numbers3, model.Numbers4, model.Numbers5, model.Numbers6 } }; TicketRepo.Add(ticket); return(View("DisplayTicket", TicketRepo.GetAll().LastOrDefault())); //if !IsValid: return View(model); }
public async Task <IActionResult> AddTicket(AddTicketViewModel ticketModel, int eventId) { var ticket = new Ticket { EventId = eventId, SellerId = userManager.GetUserId(User), Price = ticketModel.Price, SellerNotes = ticketModel.Notes, Status = TicketStatuses.Selling }; await ticketsService.AddTicket(ticket); return(View("InstructionTicketAdded")); }
public ActionResult AddTicket(AddTicketViewModel model) { model.Categories = unitOfWork.Categories.GetListCategories(); if (ModelState.IsValid) { var ticket = new Tickets { Author = User.Identity.GetUserId(), Title = model.Title, Priority = model.Priority, Description = model.Description, Screenshot = model.Screenshot, Category = model.Category }; unitOfWork.Tickets.Create(ticket); unitOfWork.Save(); return RedirectToAction("Index", "Home"); } return View(model); }
public int AddTicketInMatch(AddTicketViewModel model) { var LastTicketId = GetMatches().Last().Id; var ticket = new Ticket() { Id = LastTicketId + 1, MatchName = model.MatchName, Price = model.Price, Sector = model.Sector }; var response = _ticketRepository.Insert(ticket); return(response); }
public IActionResult Edit(AddTicketViewModel ticketViewModel) { if (ModelState.IsValid) { var ticketToEdit = _repo.GetTicket(ticketViewModel.Id); ticketToEdit.Title = ticketViewModel.Title; ticketToEdit.Description = ticketViewModel.Description; ticketToEdit.TicketStatus = ticketViewModel.TicketStatus; ticketToEdit.TicketPriority = ticketViewModel.TicketPriority; ticketToEdit.Type = ticketViewModel.Type; ticketToEdit.ProjectID = ticketViewModel.ProjectID; ticketToEdit.AssignedToId = ticketViewModel.AssignedToId; _repo.EditTicket(ticketToEdit); return(Redirect("/Tickets")); } return(View(ticketViewModel)); }
public IActionResult Add(AddTicketViewModel addTicketViewModel) { if (ModelState.IsValid) { // Add the new user to my existing users Customers newCustomer = context.Customer.Single(c => c.ID == addTicketViewModel.CustomerID); Tickets newTicket = new Tickets { Hours = addTicketViewModel.Hours, Comments = addTicketViewModel.Comments, Invoiced = "N", AmountInvoiced = (100 * addTicketViewModel.Hours), CustomerID = addTicketViewModel.CustomerID }; context.Tickets.Add(newTicket); context.SaveChanges(); return(Redirect("/Ticket")); } return(View(addTicketViewModel)); }
public void AddTicketToDB(AddTicketViewModel ticket) { var dbTicket = Mapper.Map <Ticket>(ticket); if (ticket.UploadedImage != null) { using (var memory = new MemoryStream()) { ticket.UploadedImage.InputStream.CopyTo(memory); var content = memory.GetBuffer(); dbTicket.Image = new Image { Content = content, FileExtension = ticket.UploadedImage.FileName.Split('.')[1] }; }; } this.Data.Tickets.Add(dbTicket); this.Data.SaveChanges(); }
public ActionResult EnterNew() { AddTicketViewModel model = new AddTicketViewModel(); return(View(model)); }
public async Task <IActionResult> ProcessAddTicketAsync(AddTicketViewModel addTicketViewModel) { if (ModelState.IsValid) { //if you want to add files to server use below code /*string uniqueFileName1 = null; * string uniqueFileName2 = null; * string uniqueFileName3 = null; * * if (addTicketViewModel.Photo1 != null) * { * // The image must be uploaded to the images folder in wwwroot * // To get the path of the wwwroot folder we are using the inject * // HostingEnvironment service provided by ASP.NET Core * string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images"); * // To make sure the file name is unique we are appending a new * // GUID value and and an underscore to the file name * uniqueFileName1 = Guid.NewGuid().ToString() + "_" + addTicketViewModel.Photo1.FileName; * string filePath = Path.Combine(uploadsFolder, uniqueFileName1); * // Use CopyTo() method provided by IFormFile interface to * // copy the file to wwwroot/images folder * addTicketViewModel.Photo1.CopyTo(new FileStream(filePath, FileMode.Create)); * } * if (addTicketViewModel.Photo2 != null) * { * // The image must be uploaded to the images folder in wwwroot * // To get the path of the wwwroot folder we are using the inject * // HostingEnvironment service provided by ASP.NET Core * string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images"); * // To make sure the file name is unique we are appending a new * // GUID value and and an underscore to the file name * uniqueFileName2 = Guid.NewGuid().ToString() + "_" + addTicketViewModel.Photo2.FileName; * string filePath = Path.Combine(uploadsFolder, uniqueFileName2); * // Use CopyTo() method provided by IFormFile interface to * // copy the file to wwwroot/images folder * addTicketViewModel.Photo2.CopyTo(new FileStream(filePath, FileMode.Create)); * } * if (addTicketViewModel.Photo3 != null) * { * // The image must be uploaded to the images folder in wwwroot * // To get the path of the wwwroot folder we are using the inject * // HostingEnvironment service provided by ASP.NET Core * string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images"); * // To make sure the file name is unique we are appending a new * // GUID value and and an underscore to the file name * uniqueFileName3 = Guid.NewGuid().ToString() + "_" + addTicketViewModel.Photo3.FileName; * string filePath = Path.Combine(uploadsFolder, uniqueFileName3); * // Use CopyTo() method provided by IFormFile interface to * // copy the file to wwwroot/images folder * addTicketViewModel.Photo3.CopyTo(new FileStream(filePath, FileMode.Create)); * }*/ //adds uploaded files to database if (Request.Form.Files.Count == 1) { IFormFile file = Request.Form.Files.FirstOrDefault(); using (var dataStream = new MemoryStream()) { await file.CopyToAsync(dataStream); addTicketViewModel.Picture1 = dataStream.ToArray(); } } else if (Request.Form.Files.Count == 2) { IFormFile[] file = new IFormFile[2]; file[0] = Request.Form.Files[0]; using (var dataStream1 = new MemoryStream()) { await file[0].CopyToAsync(dataStream1); addTicketViewModel.Picture1 = dataStream1.ToArray(); } file[1] = Request.Form.Files[1]; using (var dataStream2 = new MemoryStream()) { await file[1].CopyToAsync(dataStream2); addTicketViewModel.Picture2 = dataStream2.ToArray(); } } else if (Request.Form.Files.Count == 3) { IFormFile[] file = new IFormFile[3]; file[0] = Request.Form.Files[0]; using (var dataStream1 = new MemoryStream()) { await file[0].CopyToAsync(dataStream1); addTicketViewModel.Picture1 = dataStream1.ToArray(); } file[1] = Request.Form.Files[1]; using (var dataStream2 = new MemoryStream()) { await file[1].CopyToAsync(dataStream2); addTicketViewModel.Picture2 = dataStream2.ToArray(); } file[2] = Request.Form.Files[2]; using (var dataStream3 = new MemoryStream()) { await file[2].CopyToAsync(dataStream3); addTicketViewModel.Picture3 = dataStream3.ToArray(); } } ApplicationUser NewApplicationUser = context.Users.Find(addTicketViewModel.UserId); Ticket newTicket = new Ticket { Description = addTicketViewModel.Description, User = NewApplicationUser, /*PhotoPath1 = uniqueFileName1, * PhotoPath2 = uniqueFileName2, * PhotoPath3 = uniqueFileName3,*/ Picture1 = addTicketViewModel.Picture1, Picture2 = addTicketViewModel.Picture2, Picture3 = addTicketViewModel.Picture3 }; context.Tickets.Add(newTicket); context.SaveChanges(); return(Redirect("/ticket")); } return(View("Add", addTicketViewModel)); }
public IActionResult Add() { AddTicketViewModel addTicketViewModel = new AddTicketViewModel(); return(View(addTicketViewModel)); }
public async Task <IActionResult> EditAsync(AddTicketViewModel addTicketViewModel) { Ticket theTicket = context.Tickets.Find(addTicketViewModel.Id); if (Request.Form.Files.Count == 1) { IFormFile file = Request.Form.Files.FirstOrDefault(); using (var dataStream = new MemoryStream()) { await file.CopyToAsync(dataStream); addTicketViewModel.Picture1 = dataStream.ToArray(); } } else if (Request.Form.Files.Count == 2) { IFormFile[] file = new IFormFile[2]; file[0] = Request.Form.Files[0]; using (var dataStream1 = new MemoryStream()) { await file[0].CopyToAsync(dataStream1); addTicketViewModel.Picture1 = dataStream1.ToArray(); } file[1] = Request.Form.Files[1]; using (var dataStream2 = new MemoryStream()) { await file[1].CopyToAsync(dataStream2); addTicketViewModel.Picture2 = dataStream2.ToArray(); } } else if (Request.Form.Files.Count == 3) { IFormFile[] file = new IFormFile[3]; file[0] = Request.Form.Files[0]; using (var dataStream1 = new MemoryStream()) { await file[0].CopyToAsync(dataStream1); addTicketViewModel.Picture1 = dataStream1.ToArray(); } file[1] = Request.Form.Files[1]; using (var dataStream2 = new MemoryStream()) { await file[1].CopyToAsync(dataStream2); addTicketViewModel.Picture2 = dataStream2.ToArray(); } file[2] = Request.Form.Files[2]; using (var dataStream3 = new MemoryStream()) { await file[2].CopyToAsync(dataStream3); addTicketViewModel.Picture3 = dataStream3.ToArray(); } } theTicket.Description = addTicketViewModel.Description; theTicket.Picture1 = addTicketViewModel.Picture1; theTicket.Picture2 = addTicketViewModel.Picture2; theTicket.Picture3 = addTicketViewModel.Picture3; context.Tickets.Update(theTicket); context.SaveChanges(); return(Redirect("/ticket")); }