public async Task <IActionResult> Get(long ticketTypeId) { var currentUser = await _identityService.GetCurrentUser(); if (currentUser == null) { return(BadRequest(new { error = "You are not allowed!" })); } var person = await _identityService.GetPersonByUserId(currentUser.Id); if (person == null) { return(BadRequest(new { error = "Person was not found" })); } var item = await _ticketTypeService.GetTicketTypeById(ticketTypeId); if (item == null) { return(NotFound()); } //var itemDto = new TicketTypeDto //{ // Id = item.Id, // Name = item.Name, // ShortName = item.ShortName, // Deleted = item.Deleted //}; return(Ok(_mapper.Map <TicketTypeDto>(item))); }
public async Task <IActionResult> UpdateAsync([FromBody] TicketDto model) { if (model == null) { return(NotFound()); } var currentUser = await _identityService.GetCurrentUser(); if (currentUser == null) { return(BadRequest(new { error = "You are not allowed!" })); } var person = await _identityService.GetPersonByUserId(currentUser.Id); if (person == null) { return(BadRequest(new { error = "Person was not found" })); } var ticket = await _ticketService.GetTicketById(model.Id); if (ticket == null) { return(BadRequest(new { error = "Selected ticket was not found" })); } var eventParent = await _eventParentService.GetEventParentById(model.EventParentId); if (eventParent == null) { return(BadRequest(new { error = "Selected event child was not found" })); } var ticketType = await _ticketTypeService.GetTicketTypeById(model.TicketTypeId); if (ticketType == null) { return(BadRequest(new { error = "Selected ticket type was not found" })); } var existingType = await _ticketService.ExistingTicketType(model.TicketTypeId, model.EventParentId, model.Id); if (existingType) { return(BadRequest(new { error = "Event child can not have the same ticket type twice" })); } ticket.EventParentId = model.EventParentId; ticket.Price = model.Price; ticket.Remaining = model.Remaining; ticket.TicketTypeId = model.TicketTypeId; ticket.Deleted = model.Deleted; await _ticketService.UpdateTicket(ticket); return(Ok()); }
public async Task <IActionResult> UpdateTicketType([FromForm] TicketTypeUM ticketTypeUM) { try { var TicketType = _ITicketTypeService.GetTicketTypeById(ticketTypeUM.Id); if (TicketType == null) { return(NotFound()); } var auth = FirebaseAdmin.Auth.FirebaseAuth.DefaultInstance; IList <IFormFile> imageUpload = ticketTypeUM.ImageUpload.ToList(); List <String> listImage = new List <string>(); if (imageUpload.Count > 0) { for (int i = 0; i < imageUpload.Count; i++) { var file = imageUpload[i]; //Stream ms = file.OpenReadStream(); //var cancellation = new CancellationTokenSource(); //var task = new FirebaseStorage( //"citypass131999.appspot.com", //new FirebaseStorageOptions //{ // AuthTokenAsyncFactory = () => Task.FromResult("eyJhbGciOiJSUzI1NiIsImtpZCI6IjRlMDBlOGZlNWYyYzg4Y2YwYzcwNDRmMzA3ZjdlNzM5Nzg4ZTRmMWUiLCJ0eXAiOiJKV1QifQ.eyJhZG1pbiI6dHJ1ZSwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL2NpdHlwYXNzMTMxOTk5IiwiYXVkIjoiY2l0eXBhc3MxMzE5OTkiLCJhdXRoX3RpbWUiOjE2MTY1NTQzNTksInVzZXJfaWQiOiJscURaSE45T05tZU12MWJQdmk4SjVzS1VQR1YyIiwic3ViIjoibHFEWkhOOU9ObWVNdjFiUHZpOEo1c0tVUEdWMiIsImlhdCI6MTYxNjU1NDM1OSwiZXhwIjoxNjE2NTU3OTU5LCJlbWFpbCI6InRoaW5oQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6eyJlbWFpbCI6WyJ0aGluaEBnbWFpbC5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.Fo4-suiJN2srzcicYejDGGero5nFmNj-SWfgMA-YcLbfgfHgA1P8gcg1Y9-Kc2bJTffEhpYTiqgUgft9TRMgDSyUsUt4xLpNC77KqjbGEPM5iqrMOepJAm6A6XLizq9s-ija2BIIrUXDkIHkTaVwC_Q5zsVcmiRZkUo8A_RHW-U7-4juCGkKs8o0tjvrSi-64XDcl8OLUbCWeACYfeJw2lcQvH4I4NgZrdXJcgUi9oHQJ8CqyqmUWdIwnLgF6ETRIgolflK0kjNWpO9HA0b2Avu4zggp9DQfPlw3wID3WZG8Pe7c-2Og3pKj8ymVOZnqegvemJkWLtu7Qqin0RynPA"), // ThrowOnCancel = true // when you cancel the upload, exception is thrown. By default no exception is thrown //}) //.Child("ticket-type") //.Child($"{ticketTypeUM.Id}") //.Child(file.Name + DateTime.Now.ToString()) //.PutAsync(ms, cancellation.Token); var link = await _iUploadFile.uploadFile(file, ticketTypeUM.Id.ToString()); listImage.Add(link); } } listImage.AddRange(ticketTypeUM.UrlImages); TicketType.UrlImage = String.Join(";", listImage); TicketType.Name = ticketTypeUM.Name; //TicketType.UrlImage = ticketTypeUM.UrlImage; TicketType.AdultPrice = ticketTypeUM.AdultPrice; TicketType.ChildrenPrice = ticketTypeUM.ChildrenPrice; TicketType.AtrractionId = ticketTypeUM.AtrractionId; _ITicketTypeService.UpdateTicketType(TicketType); bool result = await _ITicketTypeService.SaveTicketType(); if (!result) { return(BadRequest("Can not update TicketType")); } return(Ok(TicketType)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult Details(int?id) { logger.Info(nameof(TicketController.Index)); if (id == null) { logger.Warn(nameof(TicketTypeController.Details) + " id is null"); return(NotFound()); } try { var ticketTypeDto = ticketTypeService.GetTicketTypeById(id.Value); if (ticketTypeDto == null) { logger.Warn(nameof(TicketTypeController.Details) + " ticketType is null"); return(NotFound()); } return(View(ticketTypeDto)); } catch (Exception exception) { logger.Error(exception); return(BadRequest()); } }
public decimal GetTicketPrice(IEnumerable <int> areasId, int ticketTypeId) { var ticketType = ticketTypeService.GetTicketTypeById(ticketTypeId); var coefficient = ticketType.Coefficient; var ticketPrice = CalculateTicketPrice(areasId); var totalPrice = ticketPrice * coefficient; return(totalPrice); }
public ActionResult Create(int?id) { var model = new TicketTypeModel { IsActive = true }; if (id != null) { model = ticketTypeService.GetTicketTypeById((int)id).MapFromServerToClient(); } return(View(model)); }
public IActionResult Create(TicketDto ticketDto) { log.Info(nameof(TicketController.Create) + ":Post"); try { TicketTypeDto ticketType = null; ticketType = ticketTypeService.GetTicketTypeById(ticketDto.TicketTypeId); if (ticketType.IsPersonal && ticketDto.UserId == null) { ModelState.AddModelError("", "User is not specified for personal ticket type"); InitViewDataForSelectList(); return(View(ticketDto)); } if (ModelState.IsValid) { ticketService.Create(ticketDto); return(RedirectToAction(nameof(Index))); } InitViewDataForSelectList(ticketDto); return(View(ticketDto)); } catch (Exception e) { log.Error(e); return(BadRequest()); } }
public IActionResult GetTicketType([SwaggerParameter("Int", Required = true)] int id) { logger.Info(nameof(TicketTypesController.GetTicketType)); try { return(Ok(ticketTypeService.GetTicketTypeById(id))); } catch (Exception exception) { logger.Error(exception); return(BadRequest()); } }