public async Task <Buyer> Register(BuyerForRegisterDto buyerinfo)
        {
            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(buyerinfo.Password, out passwordHash, out passwordSalt);
            var buyer = mapper.Map <Buyer>(buyerinfo);

            buyer.PasswordHash = passwordHash;
            buyer.PasswordSalt = passwordSalt;

            await context.Buyers.AddAsync(buyer);

            return(buyer);
        }
        public async Task <IActionResult> Register(BuyerForRegisterDto buyerinfo)
        {
            buyerinfo.FullName = buyerinfo.FullName.ToLower();
            if (await repo.BuyerExists(buyerinfo.FullName) != 0)
            {
                return(BadRequest());
            }
            var createdBuyer = await repo.Register(buyerinfo);

            if (await repo.SaveAll())
            {
                var buyerid = await repo.BuyerExists(createdBuyer.FullName);

                var buyerToreturn = mapper.Map <BuyerToReturn>(createdBuyer);
                buyerToreturn.Id = buyerid;
                return(CreatedAtRoute("GetBuyer", new { id = createdBuyer.Id }, buyerToreturn));
            }
            return(BadRequest());
        }