Пример #1
0
        public async Task <IActionResult> UpdateAsync(Hall hallIn)
        {
            hallIn.Id.ValidateId();

            var hall = await _hallsRepository.GetAsync(hallIn.Id);

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

            try
            {
                await _hallsRepository.UpdateAsync(hallIn.Id, hallIn);
            }
            catch (Exception)
            {
                throw new Error(Errors.Update_error, $"Can not update record {hall}");
            }
            return(NoContent());
        }
Пример #2
0
        public async Task Edit(HallViewModel hall, byte[] photo, IFormFile file)
        {
            var initialHall = await _hallsRepository.GetAsync(hall.Id);

            hall.Stands = initialHall.Stands;

            if (initialHall.Photo != null)
            {
                hall.Photo = initialHall.Photo;
                if (photo == null)
                {
                    hall.Photo.Photo = null;
                }
            }

            if (file != null)
            {
                await _formFileToByteConverterService.ConvertAsync(file, hall);
            }

            await _hallsRepository.UpdateAsync(hall.Id, hall);
        }