public Ticket CreateTicket(int reservationId, string fName, string lName) { var res = _resRepo.Get(reservationId); if (res.TicketId != null) { throw new InvalidOperationException("ticket has been already issued to this reservation, unable to create another one"); } var placeInRun = _runRepository.GetPlaceInRun(res.PlaceInRunId); var newTicket = new Ticket() { ReservationId = res.Id, CreatedDate = DateTime.Now, FirstName = fName, LastName = lName, Status = TicketStatusEnum.Active, PriceComponents = new List <PriceComponent>() }; newTicket.PriceComponents = _priceStr.CalculatePrice(placeInRun); res.TicketId = newTicket.Id; _resRepo.Update(res); _tickRepo.Create(newTicket); return(newTicket); }
public async Task <IActionResult> Create(TicketForCreationDto ticket) { ticket.CreatorId = HttpContext.GetUserId(); if (!await _users.UserExist(ticket.CreatorId) || !await _users.UserExist(ticket.AssigneeId) || !await _teams.ExistById(ticket.TeamId)) { return(BadRequest("Bad request data, data don't exist.")); } var team = await _teams.GetById(ticket.TeamId); if (!await _organizations.OrganizationExistById(team.Organization.Id) || !await _organizations.UserInOrganization(ticket.CreatorId, team.Organization.Id)) { return(BadRequest($"User has no access to Organization with ID {team.Organization.Id}.")); } var taskToCreate = new Ticket { Title = ticket.Title, Description = ticket.Description, CreatorId = ticket.CreatorId, AssigneeId = ticket.AssigneeId, OrganizationId = team.Organization.Id, TeamId = team.Id, Created = DateTime.Now, LastUpdated = DateTime.Now, }; var taskCreated = await _repo.Create(taskToCreate); var taskToReturn = _mapper.Map <TicketForListDto>(taskCreated); return(Ok(taskToReturn)); }
public bool CreateTicket(Ticket ticket) { ticket.SetId(GetMaxId() + 1); Event ev = eventRepo.FindById(ticket.GetEventId()); ev.SetNoTickets(ev.GetNoTickets() - 1); eventRepo.Update(ev); return(ticketRepo.Create(ticket)); }
public void Handle(RegisterTicket command) { var id = _ticketRepository.GetNextId(TicketSeq); var ticketId = new TicketId(id); var ticketType = new TicketType(command.Type); var schoolId = new SchoolId(command.SchoolId); var ticket = new Ticket(ticketId, ticketType, schoolId, command.Message); _ticketRepository.Create(ticket); }
public async Task ExecuteAsync(CreateTicketCommand command) { if (await _ticketRepository.GetById(command.Id) != null) { throw new Exception("Ticket with same Id already exists"); } var ticket = _mapper.Map <Airport.Domain.Entities.Ticket>(command); await _ticketRepository.Create(ticket); }
public long Execute() { if (Input == null) { return(-1); } var ticket = new domain.Ticket(Input.OpenedById, Input.State, Input.Description, Input.PlaceId, Input.Title, Input.Created); return(ticketRepository.Create(ticket)); }
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); }
// POST: api/Ticket public void Post([FromBody] ProductRequestItem item) { var ticket = new TicketDTO { ProductNumber = item.Product.PartNumber, StartTime = DateTime.Now, LastModifiedBy = Environment.UserName, Quantity = item.Quantity, Status = TicketStatus.Printed, DropoffLocation = item.Product.DropoffLocation, ProductId = item.Product.ID }; ticketRepository.Create(ticket); }
public void CreateTicket(CreateTicketViewModel ticketViewModel, int userId) { ValidateNumbers(ticketViewModel.Combination); var combination = string.Join(";", ticketViewModel.Combination.Split(';').Select(c => int.Parse(c)).OrderBy(x => x)); var round = _roundRepository.GetAll().FirstOrDefault(r => string.IsNullOrEmpty(r.WinningComination)); if (round == null) { throw new Exception("No Active round!"); } round.PayIn = round.PayIn == null ? round.PayIn = 0 + 50 : round.PayIn += 50; _roundRepository.Update(round); var user = _userRepository.GetById(userId); if (user == null) { throw new Exception("There is no User with that Id"); } user.Balance -= 50; if (user.Balance < 0) { throw new Exception("You don't have money for the Ticket"); } _userRepository.Update(user); var model = new Ticket { Combination = combination, UserId = userId, Status = Status.Pending, DateCreated = DateTime.Now, Round = round.Id }; _ticketRepository.Create(model); }
public IActionResult Create(Ticket ticket) { try { ticket.TicketId = Guid.NewGuid(); ticket.TicketStatus = ticket.TicketStatus ?? 0; if (ModelState.IsValid) { return(Conflict()); } ticketRepository.Create(ticket); return(Ok(ticket)); } catch (Exception ex) { return(Conflict(ex)); } }
public ActionResult Update(Ticket vm) { ApiResult <Ticket> apiResult; if (ModelState.IsValid) { if (vm.Id > 0) { apiResult = TryExecute(() => { var ticket = _ticketRepository.Get(vm.Id); ticket.TicketCategoryId = vm.TicketCategoryId; ticket.TicketSubCategoryId = vm.TicketSubCategoryId; ticket.Title = vm.Title; ticket.Description = vm.Description; ticket.DueDate = vm.DueDate; ticket.UpdatedByUserId = WebUser.Id; _unitOfWork.Commit(); return(ticket); }, "Ticket updated sucessfully"); } else { apiResult = TryExecute(() => { vm.CreatedByUserId = WebUser.Id; _ticketRepository.Create(vm); _unitOfWork.Commit(); return(vm); }, "Ticket created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <Ticket>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(CreateTicketViewModel vm) { if (ModelState.IsValid) { var newTicket = new Ticket { TicketCategoryId = vm.TicketCategoryId, TicketSubCategoryId = vm.TicketSubCategoryId, Title = vm.Title, Description = vm.Description, DueDate = vm.DueDate, Status = vm.Status, AssignedToUserId = vm.AssignedToUserId, CreatedByUserId = WebUser.Id }; // Assign to Default point of contact. var selectedCategory = _ticketCategoryRepository.Get(vm.TicketCategoryId); var pointOfContact = _ticketService.GetPointOfContact(selectedCategory.Title); newTicket.AssignedToUserId = pointOfContact; _ticketRepository.Create(newTicket); _unitOfWork.Commit(); #if !DEBUG _emailComposerService.TicketCreated(newTicket.Id); #endif return(RedirectToAction("Index")); } // Special Case where the sub categories should be based on the category var categories = _ticketCategoryRepository.GetAll().ToList(); var subCategories = _ticketSubCategoryRepository.GetAllBy(s => s.TicketCategoryId == vm.TicketCategoryId); ViewBag.TicketCategoryId = new SelectList(categories, "Id", "Title", vm.TicketCategoryId); ViewBag.TicketSubCategoryId = new SelectList(subCategories, "Id", "Title", vm.TicketSubCategoryId); return(View()); }
public async Task <int> CreateAsync(TicketAddViewModel ticket) { var request = ticket.ToTicketModel(); return(await _ticket.Create(request)); }
public async Task <TicketViewModel> CreateTicket(TicketViewModel newTicketVM) { // Ensure the project name exists before creating anything. var projectToUpdate = _projectRepo.GetByName(newTicketVM.ProjectName); if (projectToUpdate == null) { _logger.LogError($"\tThe Ticket's project '{newTicketVM.ProjectName}' could not be found in the DB"); return(null); } string log = ""; // Pass the new ticket into the database and return the newly created id var newTicket = new Ticket() { Name = newTicketVM.Name, Description = newTicketVM.Description, ProjectName = newTicketVM.ProjectName, Status = "open", Creator = newTicketVM.Creator }; // If there is at least one video file attached, pass through to video manager to upload var videoFiles = newTicketVM.VideoFiles; if (videoFiles != null && videoFiles.Count > 0) { // Upload the videos via VideoManager and return video meta data newTicket.Videos = await _videoManager.Upload(videoFiles, newTicketVM.VideoThumbnails); foreach (var videoData in newTicket.Videos) { log += $"Video '{videoData.Title}' uploaded. "; } // Remove the videoFiles since they have already been uploaded newTicketVM.VideoFiles = null; newTicketVM.VideoThumbnails = null; } newTicket.EventLog = new List <Log> { new Log { DateAndTime = DateTime.Now, Event = log += "Ticket created." } }; // create the ticket in the db and pass the new id into the view model await _ticketRepo.Create(newTicket); newTicketVM.Id = newTicket.Id; newTicketVM.Videos = newTicket.Videos; newTicketVM.Status = newTicket.Status; newTicketVM.EventLog = newTicket.EventLog; // Update the project in the DB with the created ticket's id and name UpsertTicketBaseToProject(projectToUpdate, newTicket.Id, newTicket.Name); await _projectRepo.Update(projectToUpdate); // Transfer properties to a ViewModel to return back to the controller return(newTicketVM); }
public void CreateTicket(TicketDTO item) { ticketRepo.Create(Mapper.Map <TicketDTO, Ticket>(item)); }
public int Create(Ticket ticket) { return(_repository.Create(ticket)); }
public async Task <IActionResult> CreateTicket([FromBody] TicketCreateDto ticketCreate) { var createdById = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); User createdBy = await _userRepo.GetUser(createdById); if (createdBy == null) { ModelState.AddModelError("CreatedBy", "User does not exist"); } User assignedTo = await _userRepo.GetUser(ticketCreate.AssignedToId); if (assignedTo == null) { ModelState.AddModelError("AssignedTo", "User does not exist"); } Client client = await _clientRepo.GetClient(ticketCreate.ClientId); if (client == null) { ModelState.AddModelError("Client", "Client does not exist"); } ConfigItem item = await _clientRepo.GetConfigItem(ticketCreate.ConfigItemId); if (item == null) { ModelState.AddModelError("Config Item", "Configuration Item does not exist"); } TicketPriority priority = await _repo.GetTicketPriority(ticketCreate.TicketPriorityId); if (priority == null) { ModelState.AddModelError("Ticket Priority", "Priority does not exist"); } TicketStatus status = await _repo.GetTicketStatus(ticketCreate.TicketStatusId); if (status == null) { ModelState.AddModelError("Ticket Status", "Ticket Status does not exist"); } TicketType type = await _repo.GetTicketType(ticketCreate.TicketTypeId); if (type == null) { ModelState.AddModelError("Ticket Type", "Ticket Type does not exisit"); } TicketQueue queue = await _repo.GetTicketQueue(ticketCreate.TicketQueueId); if (queue == null) { ModelState.AddModelError("Queue", "Ticket Queue does not exisit"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var createdAt = DateTime.Now; var updatedAt = DateTime.Now; Ticket newTicket = new Ticket { Description = ticketCreate.Description, Details = ticketCreate.Details, CreatedAt = createdAt, UpdatedAt = updatedAt, AssignedTo = assignedTo, CreatedBy = createdBy, TicketPriority = priority, TicketStatus = status, TicketType = type, TicketQueue = queue, Client = client, ConfigItem = item }; _repo.Create(newTicket); if (await _repo.Save()) { var ticketToReturn = _mapper.Map <TicketDetailDto>(newTicket); return(CreatedAtRoute("GetTicket", new { controller = "Tickets", id = newTicket.Id }, ticketToReturn)); } return(BadRequest()); }
public async Task <int> Create(Ticket entity) { return(await _ticketRepo.Create(entity)); }