示例#1
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <DataContext>().UseSqlite("Data Source=C:/Users/PC/source/repos/DatingApp/DatingApp.API/DatingApp.db").Options;

            _context = new DataContext(options);
            _repo    = new DatingRepository(_context);
            Seed.SeedUsers(_context);
        }
 public AuthController(IConfiguration config, IMapper mapper,
                       UserManager <User> userManager, SignInManager <User> signInManager,
                       DatingRepository repo)
 {
     this._repo          = repo;
     this._signInManager = signInManager;
     this._userManager   = userManager;
     this._mapper        = mapper;
     this._config        = config;
 }
示例#3
0
        public void SetUp()
        {
            var options =
                new DbContextOptionsBuilder <DataContext>().UseSqlite("DataSource=datingapp.db", x => { })
                .Options;

            // new instance of ElectronicsContext will be created for every test.
            _dataContext = new DataContext(options);
            _dataContext.Database.OpenConnection();
            _dataContext.Database.EnsureCreated();

            // Use _context to insert initial data required for the test
            //Seed.SeedUsers(_dataContext);
            _datingRepository = new DatingRepository(_dataContext);
        }
示例#4
0
        public PhotosController(DatingRepository repo, IMapper mapper,
                                IOptions <CloudinarySettings> cloudinaryConfig)
        {
            this._cloudinaryConfig = cloudinaryConfig;
            this._mapper           = mapper;
            this._repo             = repo;

            Account acc = new Account(
                _cloudinaryConfig.Value.CloudName,
                _cloudinaryConfig.Value.ApiKey,
                _cloudinaryConfig.Value.ApiSecret
                );

            _cloudinary = new Cloudinary(acc);
        }
示例#5
0
        public PhotosController(DatingRepository datingRepository,
                                IOptions <CloudinarySettings> cloudinarySettings, IMapper mapper)
        {
            this.datingRepository = datingRepository;

            this._cloudinarySettings = cloudinarySettings;
            this._mapper             = mapper;
            Account account = new Account(
                _cloudinarySettings.Value.AccountName,
                _cloudinarySettings.Value.ApiKey,
                _cloudinarySettings.Value.ApiSecrets
                );

            this._cloudinary = new Cloudinary(account);
        }
示例#6
0
        public async Task <IActionResult> GetUsers([FromQuery] UserParams userParams)
        {
            // List<User> a = new List<User>();
            // Console.WriteLine(a.Count());

            // if(HttpContext.Session.GetInt32("id") != null)
            // {
            //     var i = HttpContext.Session.GetInt32("id");
            //     return Ok(i);
            // }

            DatingRepository _rrepo = new DatingRepository(this._options);

            var currentUserId = int.Parse(HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value);

            // var userFromRepo = await _repo.GetUser(currentUserId);
            userParams.UserId = currentUserId;
            // if(string.IsNullOrEmpty(userParams.Gender))
            // {
            //     userParams.Gender = userFromRepo.Gender == "male" ? "female" : "male";
            // }

            var users = await _rrepo.GetUsers(userParams);

            var userToReturn = _mapper.Map <IEnumerable <UserForListDto> >(users.res);

            // var a = userToReturn.AsQueryable().OrderBy(u => u.Gender);
            Response.AddPagination(users.CurrentPage, users.PageSize, users.TotalCount, users.TotalPage);
            var page = new PaginationHeader(users.CurrentPage, users.PageSize, users.TotalCount, users.TotalPage);

            // return Ok(userToReturn);
            return(Ok(new
            {
                page,
                userToReturn
            }));
        }
示例#7
0
 public ManController(DatingRepository repo)
 {
     this.repo = repo;
 }
示例#8
0
 public ResultController(DatingRepository repo, IEnumerable <IPersonValidator> validators)
 {
     this.repo       = repo;
     this.validators = validators;
 }
示例#9
0
 public UsersController(DatingRepository repo, IMapper mapper)
 {
     this._mapper = mapper;
     this._repo   = repo;
 }
示例#10
0
 public OfertasController(DatingRepository repo, IMapper mapper)
 {
     this._repo   = repo;
     this._mapper = mapper;
 }