Exemplo n.º 1
0
        public void ChangePrice(int prodId, decimal brutPrice)
        {
            var prod = _ctx.Products.First(x => x.ProdId == prodId);

            prod.BrutPrice        = brutPrice;
            prod.ProdPriceChanged = DateTime.UtcNow.Date;
            _ctx.SaveChanges();
        }
Exemplo n.º 2
0
        public void Registration(Interfaces.IUserDTO udto)
        {
            if (string.IsNullOrWhiteSpace(udto.UserPassword))
            {
                throw new ApplicationException("Password is needed");
            }
            if (string.IsNullOrWhiteSpace(udto.UserName))
            {
                throw new ApplicationException("Username is needed");
            }
            if (_ctx.Users.Any(x => x.UserName == udto.UserName))
            {
                throw new ApplicationException("Username is taken");
            }
            if (_ctx.Users.Any(x => x.Email == udto.Email))
            {
                throw new ApplicationException("There is a registered user with this e-mail address");
            }

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(udto.UserPassword, out passwordHash, out passwordSalt);

            User u = new User
            {
                Email        = udto.Email.ToLower(),
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                UserName     = udto.UserName
            };

            _ctx.Add(u);
            _ctx.SaveChanges();
        }