Beispiel #1
0
        public async Task <Entities.WashingTime.WashingTime> Update(Guid id, [FromBody] WashingTimeDto washingTimeDto)
        {
            var helpRequest = _mapper.Map <Entities.WashingTime.WashingTime>(washingTimeDto);

            helpRequest.Id = id;
            _repository.Update(helpRequest);
            await _repository.UnitOfWork.SaveEntitiesAsync();

            return(helpRequest);
        }
Beispiel #2
0
        public async Task <Entities.WashingTime.WashingTime> Store([FromBody] WashingTimeDto washingTimeDto)
        {
            var helpRequest = _mapper.Map <Entities.WashingTime.WashingTime>(washingTimeDto);

            helpRequest.UserId = _identityAccessor.UserId;
            _repository.Add(helpRequest);
            try
            {
                await _repository.UnitOfWork.SaveEntitiesAsync();
            }
            catch (DbUpdateException exception)
                when(exception.InnerException is PostgresException postgresException &&
                     postgresException.SqlState == SqlStateCodeStatic.UniqueViolation)
                {
                    throw new UniqueConstraintViolationException("This time is already taken");
                }

            return(helpRequest);
        }