Esempio n. 1
0
        public async Task <IActionResult> UpdateAsync(string hallId, Stand standIn)
        {
            standIn.Id.ValidateId();
            hallId.ValidateId();

            var stand = await _standsRepository.GetAsync(hallId, standIn.Id);

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

            try
            {
                await _standsRepository.UpdateAsync(hallId, standIn.Id, standIn);
            }
            catch (Exception)
            {
                throw new Error(Errors.Update_error, $"Can not update record {stand}");
            }
            return(NoContent());
        }
Esempio n. 2
0
        public async Task <StandDTO> GetAsync(HttpRequest request, string hallId, string id)
        {
            // Get language from header
            StringValues language = LanguageConstants.LanguageDefault;

            request?.Headers?.TryGetValue("Accept-Language", out language);

            var stand = await _standsRepository.GetAsync(hallId, id);

            MapperConfiguration mapperConfiguration = null;
            StandDTO            standDTO            = null;

            if (stand != null)
            {
                // Create mapping depending on language
                switch (language)
                {
                case LanguageConstants.LanguageRu:
                    mapperConfiguration = StandsMappingConfigurations.GetRuConfiguration;
                    break;

                case LanguageConstants.LanguageEn:
                    mapperConfiguration = StandsMappingConfigurations.GetEnConfiguration;
                    break;

                case LanguageConstants.LanguageBy:
                    mapperConfiguration = StandsMappingConfigurations.GetByConfiguration;
                    break;

                default:
                    mapperConfiguration = StandsMappingConfigurations.GetEnConfiguration;
                    break;
                }
                var mapper = new Mapper(mapperConfiguration);
                standDTO = mapper.Map <StandDTO>(stand);

                var exhibits = await _exhibitsService.GetAllAsync(request, hallId, id);

                standDTO.Exhibits = exhibits;
            }
            return(standDTO);
        }
Esempio n. 3
0
 public async Task <PartialViewResult> Index(string hallId, string id)
 {
     ViewBag.HallId = hallId;
     return(PartialView("~/Views/Shared/Stands/_Index.cshtml", await _standsRepository.GetAsync(hallId, id)));
 }