Пример #1
0
        private bool TryCreateReview(IProductDataAdapter productDataAdapter, string title, string content, double rating,
                                     int maximumRatingValue, string reviewerName, string reviewerLocation, string reviewerEmail, bool recommend)
        {
            if (string.IsNullOrWhiteSpace(reviewerName))
            {
                ModelState.AddModelError("reviewerName", ResourceManager.GetString("Required_Nick_Name"));
            }

            if (!Request.IsAuthenticated)
            {
                if (string.IsNullOrWhiteSpace(reviewerEmail))
                {
                    ModelState.AddModelError("reviewerEmail", ResourceManager.GetString("Required_Email"));
                }
            }

            if (string.IsNullOrWhiteSpace(title))
            {
                ModelState.AddModelError("title", ResourceManager.GetString("Required_Title"));
            }

            if (rating < 1)
            {
                ModelState.AddModelError("rating", ResourceManager.GetString("Required_Rating"));
            }

            if (!ModelState.IsValid)
            {
                return(false);
            }

            productDataAdapter.CreateReview(title, content, rating, maximumRatingValue, reviewerName, reviewerLocation, reviewerEmail, recommend);

            return(true);
        }
Пример #2
0
        private bool TryCreateReview(IProductDataAdapter productDataAdapter, string title, string content, double rating,
                                     int maximumRatingValue, string reviewerName, string reviewerLocation, string reviewerEmail, bool recommend)
        {
            if (string.IsNullOrWhiteSpace(reviewerName))
            {
                ModelState.AddModelError("reviewerName", "Your nickname is required.");
            }

            if (!Request.IsAuthenticated)
            {
                if (string.IsNullOrWhiteSpace(reviewerEmail))
                {
                    ModelState.AddModelError("reviewerEmail", "E-mail is required; it will not be displayed.");
                }
            }

            if (string.IsNullOrWhiteSpace(title))
            {
                ModelState.AddModelError("title", "Title is required.");
            }

            if (rating < 1)
            {
                ModelState.AddModelError("rating", "Rating is required.");
            }

            if (!ModelState.IsValid)
            {
                return(false);
            }

            productDataAdapter.CreateReview(title, content, rating, maximumRatingValue, reviewerName, reviewerLocation, reviewerEmail, recommend);

            return(true);
        }
Пример #3
0
 public void Init()
 {
     myRecipeDataAdapter   = NSubstitute.Substitute.For <IRecipeDataAdapter>();
     myProductAdapter      = NSubstitute.Substitute.For <IProductDataAdapter>();
     myShoppingListService = NSubstitute.Substitute.For <IShoppingListService>();
     myService             = new RecipeService(myRecipeDataAdapter, myProductAdapter, myShoppingListService);
 }
Пример #4
0
        public void Initialize()
        {
            myShoopingListAdapter = Substitute.For <IShoppingListDataAdapter>();
            myProductAdapter      = Substitute.For <IProductDataAdapter>();
            myRecipeAdapter       = Substitute.For <IRecipeDataAdapter>();

            myService = new ShoppingListService(myShoopingListAdapter, myProductAdapter, myRecipeAdapter);
        }
Пример #5
0
 public ProductService(IProductDataAdapter productDataAdapter, IProductTagService productTagService)
 {
     myProductDataAdapter   = productDataAdapter;
     this.productTagService = productTagService;
 }
Пример #6
0
 public void init()
 {
     myRecipeAdpater  = Substitute.For <IRecipeDataAdapter>();
     myProductAdpater = Substitute.For <IProductDataAdapter>();
     recipeService    = new RecipeService(myRecipeAdpater, myProductAdpater);
 }
Пример #7
0
 public ShoppingListService(IShoppingListDataAdapter shoppingListDataAdapter, IProductDataAdapter productDataAdapter, IRecipeDataAdapter recipeDataAdapter)
 {
     myShoppingListDataAdapter = shoppingListDataAdapter;
     myProductDataAdapter      = productDataAdapter;
     this.recipeDataAdapter    = recipeDataAdapter;
 }
Пример #8
0
 public RecipeService(IRecipeDataAdapter recipeAdapter, IProductDataAdapter productDataAdapter, IShoppingListService shoppingListService)
 {
     this.recipeAdapter         = recipeAdapter;
     this.productDataAdapter    = productDataAdapter;
     this.myShoppingListService = shoppingListService;
 }