Exemple #1
0
        public async Task <IActionResult> UpdateHallByIdAsync(
            [FromRoute, SwaggerParameter(Description = "The id of hall to update", Required = true)] Guid hallId,
            [FromBody, SwaggerParameter(Description = "Hall to update", Required = true)] HallToUpdateDto hallToUpdate,
            [FromHeader(Name = "Accept"), SwaggerParameter(Description = "media type to request betwen json or json+hateoas")] string mediaType)
        {
            var hallFromDb = await _hallRepository.GetHallAsync(hallId);

            // upserting if movie does not already exist
            if (hallFromDb == null)
            {
                var hallEntity = Mapper.Map <Hall>(hallToUpdate);
                hallEntity.Id = hallId;
                _hallRepository.AddHall(hallEntity);

                if (!await _hallRepository.SaveChangesAsync())
                {
                    _logger.LogError($"Upserting hall: {hallId} failed on save");
                }

                var hallToReturn = Mapper.Map <HallDto>(hallEntity);

                if (mediaType == "application/vnd.biob.json+hateoas")
                {
                    var links = CreateLinksForHall(hallToReturn.Id);

                    var linkedHall = hallToReturn.ShapeData(null) as IDictionary <string, object>;

                    linkedHall.Add("links", links);

                    return(CreatedAtRoute("GetHall", new { hallId = hallToReturn.Id }, linkedHall));
                }

                return(CreatedAtRoute("GetHall", new { hallId = hallToReturn.Id }, hallToReturn));
            }

            Mapper.Map(hallToUpdate, hallFromDb);

            _hallRepository.UpdateHall(hallFromDb);

            if (!await _hallRepository.SaveChangesAsync())
            {
                _logger.LogError($"Updating hall: {hallId} failed on save");
            }

            return(NoContent());
        }
 public bool UpdateHalls(HallMember hallMember)
 {
     return(_hallRepository.UpdateHall(new HallMemberDAO
     {
         Numbers_of_rows = hallMember.Numbers_of_rows,
         Number_of_seats = hallMember.Number_of_seats,
         HallId = hallMember.HallId
     }));
 }
Exemple #3
0
        //updating Hall
        //STILL NEEDS TO CHECK IF ANY RESERVATIONS ARE USING TIME THAT IS BEING UPDATED
        public bool UpdateHall(Hall hall)
        {
            var hallToUpdate = UpdateOpeningHours(hall);

            return(_hallRepository.UpdateHall(hallToUpdate));
        }