예제 #1
0
        public async Task <IActionResult> Create([FromBody] TicketTypeDto model)
        {
            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" }));
            }

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

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

            var ticketType = new TicketType()
            {
                Name = model.Name,
            };

            await _ticketTypeService.CreateTicketType(ticketType);

            return(Ok());
        }
예제 #2
0
        public ActionResult CreateTicketType(TicketTypeCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid Request"));
            }
            var createResult = _ticketTypeService.CreateTicketType(model);

            if (createResult == false)
            {
                return(StatusCode((int)HttpStatusCode.NotAcceptable, createResult));
            }
            return(Ok());
        }