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()); }
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); }
public async Task <PartialViewResult> Index(string hallId, string id) { ViewBag.HallId = hallId; return(PartialView("~/Views/Shared/Stands/_Index.cshtml", await _standsRepository.GetAsync(hallId, id))); }