Example #1
0
 public void ValidateIsUpdatingExistingProduct(string productId, IValidationDictionary validationDictionary)
 {
     if (_repository.Get(productId) == null)
     {
         validationDictionary.AddModelError(nameof(productId), "ProductId does not exist. Please use Post for creating a Product and Put for updating a product.");
     }
 }
Example #2
0
        public bool AuthenticateUser(string email, string password)
        {
            bool isValidCredentials = unitOfWork.UsersRepository.IsExistingEntity(u => u.Email == email && u.Password == password);

            if (isValidCredentials)
            {
                return(true);
            }
            else
            {
                validationDictionary.AddModelError("wrongCredentials", "Wrong password or not existing account.");
                return(false);
            }
        }
 public bool Add(Activity activity)
 {
     if (IsExistingActivity(a => a.Name == activity.Name))
     {
         validationDictionary.AddModelError("ExistingActivity", "There is already an activity with the same name in the database");
         bool hasSuccessfullySaved = false;
         return(hasSuccessfullySaved);
     }
     else
     {
         unitOfWork.ActivitiesRepository.Add(activity);
         bool hasSuccessfullySaved = unitOfWork.Save();
         return(hasSuccessfullySaved);
     }
 }