Example #1
0
        public async Task <UserDto> CreateAsync(UserDto user)
        {
            if (string.IsNullOrWhiteSpace(user.Name))
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(user.LastName))
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(user.Email))
            {
                return(null);
            }

            var entity = user.ConvertToEntity();

            await _context.Users.AddAsync(entity);

            await _context.SaveChangesAsync();

            return(entity.ConvertToDto());
        }