Example #1
0
        public async Task <Company> RegisterCompany(CompanyDto companyRegistration)
        {
            var company = new Company
            {
                CompanyName = companyRegistration.name.ToLower(),
            };

            _context.Companies.Add(company);
            await _context.SaveChangesAsync();

            return(company);
        }
Example #2
0
        public async Task <MarketCompany> RegisterMarketCompanyConnection(MarketCompanyDto model)
        {
            var marketCompany = new MarketCompany();

            marketCompany = new MarketCompany
            {
                Company = model.CompanyId,
                Market  = model.MarketId,
                Price   = model.Price
            };
            _context.MarketCompanies.Add(marketCompany);

            await _context.SaveChangesAsync();

            return(marketCompany);
        }
Example #3
0
        public async Task <Market> RegisterMarket(MarketDto marketRegistration)
        {
            var marketFromDb = await _context.Markets.FirstOrDefaultAsync(x => x.Name == marketRegistration.name);

            var market = new Market();

            market = new Market
            {
                Name = marketRegistration.name.ToLower(),
            };
            _context.Markets.Add(market);

            await _context.SaveChangesAsync();

            return(market);
        }
Example #4
0
        public async Task <User> RegisterUser(RegisterUserDto registerUser)
        {
            using var hmac = new HMACSHA512();
            var user = new User
            {
                UserName     = registerUser.UserName.ToLower(),
                PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(registerUser.Password)),
                PasswordSalt = hmac.Key
            };

            _context.Users.Add(user);
            await _context.SaveChangesAsync();

            return(user);
        }
Example #5
0
        public async Task <bool> SaveAll()
        {
            var result = await _context.SaveChangesAsync() > 0;

            return(result);
        }