public void DeleteCategory(int id)
        {
            var category = _dbContext.Categories.Where(x => x.Id == id).FirstOrDefault();

            _dbContext.Categories.Remove(category);
            _dbContext.SaveChanges();
        }
Exemple #2
0
        public void UpdateOffer(Offer offer)
        {
            var offerToUpdate = _dbContext.Offers.Where(x => x.Id == offer.Id).FirstOrDefault();

            offerToUpdate.IdCategory       = offer.IdCategory;
            offerToUpdate.IdMainTechnology = offer.IdMainTechnology;
            offerToUpdate.IdUser           = offer.IdUser;
            offerToUpdate.Prize            = offer.Prize;
            offerToUpdate.Title            = offer.Title;
            _dbContext.SaveChanges();
        }
        public User Create(User user, string password)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new Exception("Password is required");
            }

            if (_dbContext.Users.Any(x => x.Login == user.Login))
            {
                throw new Exception("Username \"" + user.Login + "\" is already taken");
            }

            CreatePasswordHash(password, out var passwordHash, out var passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            _dbContext.Users.Add(user);
            _dbContext.SaveChanges();

            return(user);
        }
 public void AddReview(Review review)
 {
     _dbContext.Reviews.Add(review);
     _dbContext.SaveChanges();
 }