public async Task <HallDto> AddHall(AddEditHallDto hall)
        {
            var newHall = new Hall {
                HallName = hall.Name
            };
            var result = await _halesRepository.Add(newHall);

            return(new HallDto(result));
        }
Example #2
0
        public async Task <ActionResult <HallDto> > Add([FromBody] AddEditHallDto hall)
        {
            if (string.IsNullOrEmpty(hall.Name))
            {
                return(BadRequest(new ErrorMessage("Name must not be empty")));
            }
            var result = await _halesService.AddHall(hall);

            return(Ok(result));
        }
        public async Task <HallDto> EditHall(int hallId, AddEditHallDto hall)
        {
            var editedHall = await _halesRepository.GetById(hallId);

            if (editedHall == null)
            {
                return(null);
            }
            editedHall.HallName = hall.Name;
            var result = await _halesRepository.Edit(editedHall);

            return(new HallDto(result));
        }
Example #4
0
        public async Task <ActionResult <HallDto> > Edit(int hallId, [FromBody] AddEditHallDto hall)
        {
            if (string.IsNullOrEmpty(hall.Name))
            {
                return(BadRequest(new ErrorMessage("Name must not be empty")));
            }
            var result = await _halesService.EditHall(hallId, hall);

            if (result == null)
            {
                return(NotFound(new ErrorMessage("Hall not found")));
            }
            return(Ok(result));
        }