Example #1
0
        public ActionResult NewProducts()
        {
            var repo     = new Repos.ProductRepo();
            var prodList = repo.GetAllProducts();

            return(View(prodList));
        }
Example #2
0
        public ActionResult SearchByName(string name)
        {
            var repo     = new Repos.ProductRepo();
            var prodList = repo.GetProductByName(name);

            return(View("../Product/Index", prodList));
        }
Example #3
0
        public List <console.Models.tblProduct> getAll()
        {
            var repo     = new Repos.ProductRepo();
            var prodList = repo.GetAllProducts();

            return(prodList);
        }
Example #4
0
        public void  getSession()
        {
            var repo     = new Repos.ProductRepo();
            var prodList = repo.GetAllProducts();

            Session["CartItems"] = prodList;
        }
Example #5
0
        // GET: Cart
        public ActionResult Index()
        {
            List <int?> list = (Session["CartItems"] as List <int?>) ?? new List <int?>();

            var repo     = new Repos.ProductRepo();
            var prodList = repo.GetMutipleProducts(list);

            return(View(prodList));
        }
Example #6
0
        public void GetProductsWcf_CommunicationException_EmptyEnumerable()
        {
            var mockStore = new Mock <BazzasBazaar.IStore>();

            mockStore.Setup(m => m.GetFilteredProducts(null, null, null, null)).Throws(new CommunicationException());
            var service  = new Repos.ProductRepo(mockStore.Object);
            var result   = service.GetWcfProducts().Result;
            var expected = Enumerable.Empty <Dtos.Product>();

            expected.ShouldBeEquivalentTo(result, "Expected result not equal to actual result.");
        }
Example #7
0
        private IEnumerable <Dtos.Product> _GetResults(HttpStatusCode statusCode)
        {
            MockHttpMessageHandler mockHttp = new MockHttpMessageHandler();

            mockHttp.When("http://localhost:24697/api/*").Respond(statusCode);
            HttpClient client = new HttpClient(mockHttp);

            client.BaseAddress = new Uri("http://localhost/api/");
            Dictionary <string, Uri> uri = new Dictionary <string, Uri> {
                { "Fake", new Uri("http://localhost:24697/api/Products") }
            };
            var service = new Repos.ProductRepo(client, uri);

            return(service.GetHttpProducts().Result);
        }
Example #8
0
        // GET: Product
        public ActionResult Index(int?id)
        {
            var repo = new Repos.ProductRepo();

            if (id == null)
            {
                var prodList = repo.GetAllProducts();
                return(View(prodList));
            }
            else
            {
                var prodList = repo.GetProductsByCategory(id);
                return(View(prodList));
            }
        }
Example #9
0
        public List <console.Models.tblProduct> getFeaturedProd(List <console.Models.tblFeaturedProduct> prod)
        {
            List <console.Models.tblProduct> prodList;
            List <int?> allId = new List <int?>();

            foreach (var prodId in prod)
            {
                allId.Add(prodId.product_id);
            }

            var repo = new Repos.ProductRepo();

            prodList = repo.GetMutipleProducts(allId);

            return(prodList);
        }
Example #10
0
        public void GetProductsHttp_OKWithContent_HttpProducts()
        {
            var mockHttp     = new MockHttpMessageHandler();
            var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK);

            fakeResponse.Content = new StringContent(JsonConvert.SerializeObject(mockData.HttpDataFake().Result), Encoding.UTF8, "application/json");
            mockHttp.When("http://localhost:24697/api/*").Respond(fakeResponse);
            var client = new HttpClient(mockHttp);
            Dictionary <string, Uri> uri = new Dictionary <string, Uri> {
                { "Fake", new Uri("http://localhost:24697/api/Products") }
            };
            var service  = new Repos.ProductRepo(client, uri);
            var result   = service.GetHttpProducts().Result;
            var expected = mockData.HttpDataFake().Result;

            expected.ShouldBeEquivalentTo(result, "Expected result not equal to actual result.");
        }
Example #11
0
        public ActionResult CheckOut(decimal?totalDue)
        {
            var isLogged = CheckLogin();

            if (isLogged == true)
            {
                List <int?> list = (Session["CartItems"] as List <int?>) ?? new List <int?>();

                var repo     = new Repos.ProductRepo();
                var prodList = repo.GetMutipleProducts(list);

                SaveItems(prodList, totalDue);

                return(View("Index", prodList));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Example #12
0
        public void GetProducts_WcfTimeoutException_HttpProducts()
        {
            var mockStore = new Mock <BazzasBazaar.IStore>();

            mockStore.Setup(m => m.GetFilteredProducts(null, null, null, null)).Throws(new TimeoutException());
            MockHttpMessageHandler mockHttp     = new MockHttpMessageHandler();
            HttpResponseMessage    fakeResponse = new HttpResponseMessage(HttpStatusCode.OK);

            fakeResponse.Content = new StringContent(JsonConvert.SerializeObject(mockData.HttpData().Result), Encoding.UTF8, "application/json");
            mockHttp.When("http://localhost:24697/api/*").Respond(fakeResponse);
            HttpClient client            = new HttpClient(mockHttp);
            Dictionary <string, Uri> uri = new Dictionary <string, Uri> {
                { "Fake", new Uri("http://localhost:24697/api/Products") }
            };

            var repo     = new Repos.ProductRepo(client, mockStore.Object, uri);
            var service  = new Controllers.ProductController(repo);
            var response = service.GetProductsAsync().Result;
            var results  = response.Content.ReadAsAsync <IEnumerable <Dtos.Product> >().Result;
            var expected = mockData.HttpDataFake().Result;

            expected.ShouldBeEquivalentTo(results, "Expected results not equal to actual results.");
        }