Example #1
0
 public async Task ValidateNotDeletedById <T>(IBaseDao <T> dao, long id) where T : BaseEntity <T>
 {
     if (!await dao.ExistAndNotDeletedByIdAsync(id))
     {
         var invalidEntityIdException = new InvalidEntityIdException(id, "Entity with this id does not exist!");
         Logger.Error(invalidEntityIdException, "{type} with {id} does not exist!", typeof(T), id);
         throw invalidEntityIdException;
     }
 }
Example #2
0
        private async Task <int> SoftDeleteActorFromMovieAsync(long movieId, long actorId)
        {
            var id = await _movieActorDao.SelectByIdsAsync(movieId, actorId);

            if (id <= 0)
            {
                var invalidEntityIdException = new InvalidEntityIdException(id, $"No entry found with the movie id {movieId} and actor id {actorId}!");
                Logger.Error(invalidEntityIdException, "No {Movie} and {Actor} found", movieId, actorId);
                throw invalidEntityIdException;
            }
            return(await _movieActorDao.FluentSoftDeleteById(id));
        }
Example #3
0
        public async Task <User> GetUserWithAllReferencesByUuidAsync(string uuid)
        {
            var result = await _userDao.SelectWithAllReferencesByUuidAsync(uuid);

            if (result != null)
            {
                return(result);
            }

            var invalidEntityIdException =
                new InvalidEntityIdException(0L, $"Entity with UUID \"{uuid}\" do not exist!");

            Logger.Error(invalidEntityIdException, "Entity with UUID {uuid} does not exist!", uuid);
            throw invalidEntityIdException;
        }