コード例 #1
0
 public ActionResult <List <Topping> > Get()
 {
     try
     {
         return(toppingService.GetAll());
     }
     catch (Exception exception)
     {
         return(new ObjectResult(new { Status = 500, Value = exception.Message }));
     }
 }
コード例 #2
0
        public void TestGetAll()
        {
            var testToppingEntity = new ToppingEntity()
            {
                Name = "TestName"
            };
            List <ToppingEntity> toppingEntityList = new List <ToppingEntity>()
            {
                testToppingEntity
            };

            toppingRepositoryMock.Setup(m => m.GetAll())
            .Returns(toppingEntityList);

            var result = sut.GetAll();

            Assert.AreEqual(toppingEntityList.Count, result.Count);
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: Citr0s/ShoppingCart
        public ActionResult Index()
        {
            var response = new HomeControllerIndexData
            {
                Pizzas = _pizzaSizeService.GetAll().Pizzas,
                Form   = new FormModel
                {
                    ExtraToppings = _toppingService.GetAll().Toppings.ToDictionary(x => x, y => false),
                    Sizes         = _sizeService.GetAll().Sizes.ToDictionary(x => x, y => false)
                }
            };

            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }
            else
            {
                response.Total    = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString());
                response.LoggedIn = _userSessionService.IsLoggedIn(Session["UserId"].ToString());
            }

            return(View(response));
        }
コード例 #4
0
 public IHttpActionResult GetAll()
 {
     return(Ok(_toppingService.GetAll()));
 }