// GET: storge/Details/5
        public ActionResult Details(int id)
        {
            storge mystore = cos.GetById(id);

            ViewBag.itemD = itemObj.GetById(mystore.itemID);
            return(View(mystore));
        }
 public ActionResult <IEnumerable <Item> > GetById(int id)
 {
     try
     {
         return(Ok(_is.GetById(id)));
     }
     catch (System.Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <Item> Get(int id)
 {
     try
     {
         return(Ok(_its.GetById(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemple #4
0
        public async Task GetByIdReturnsExpectedItem(Item expectedItem, ObjectId id, [Frozen] Mock <IItemsRepository> itemsRepositoryMock, ItemsService itemsService)
        {
            // Arrange
            itemsRepositoryMock.Setup(x => x.GetById(id)).ReturnsAsync(expectedItem);

            // Act
            var result = await itemsService.GetById(id.ToString());

            // Assert
            Assert.Equal(result, expectedItem);
            itemsRepositoryMock.VerifyAll();
        }
Exemple #5
0
 public ActionResult <Item> GetById(int id)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_ls.GetById(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemple #6
0
 public ActionResult <Item> GetItemsById(int id)
 {
     try
     {
         Item         item    = null;
         ItemsService service = new ItemsService();
         item = service.GetById(id);
         return(Ok(item));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message.ToString()));
     }
 }
Exemple #7
0
        public void ItemNotFound_NullReturned()
        {
            // Arrange
            var dataStoreMock = new Mock <IDataStore>(MockBehavior.Strict);

            dataStoreMock.SetupProperty(p => p.Items, new List <Item>());

            var itemsService = new ItemsService(dataStoreMock.Object);

            var unknownId = _randomInteger.GeneratePositiveValue().ToString();

            // Act
            var result = itemsService.GetById(unknownId);

            // Assert
            Assert.IsNull(result, "result == null");
        }
Exemple #8
0
        public void ItemAvailable_ItemReturned()
        {
            // Arrange
            var          description1 = _randomString.GenerateValue(50);
            var          description2 = _randomString.GenerateValue(50);
            var          endTime1     = DateTime.Now.AddHours(3);
            var          endTime2     = DateTime.Now.AddHours(4);
            var          id1          = _randomInteger.GeneratePositiveValue();
            var          id2          = _randomInteger.GeneratePositiveValue();
            const string picturePath1 = "ABC";
            const string picturePath2 = "XYZ";
            var          price1       = _randomDecimal.GeneratePositiveValue();
            var          price2       = _randomDecimal.GeneratePositiveValue();
            var          startTime1   = DateTime.Now.AddHours(-13);
            var          startTime2   = DateTime.Now.AddHours(-20);
            var          title1       = _randomString.GenerateValue(10);
            var          title2       = _randomString.GenerateValue(10);
            var          userId1      = _randomString.GenerateValue(8);
            var          userId2      = _randomString.GenerateValue(8);

            var dataStoreMock = new Mock <IDataStore>(MockBehavior.Strict);

            dataStoreMock.SetupProperty(p => p.Items, new List <Item>
            {
                new Item
                {
                    Description = description1,
                    EndTime     = endTime1,
                    Id          = id1.ToString(),
                    PicturePath = picturePath1,
                    Price       = price1,
                    StartTime   = startTime1,
                    Title       = title1,
                    UserId      = userId1
                },
                new Item
                {
                    Description = description2,
                    EndTime     = endTime2,
                    Id          = id2.ToString(),
                    PicturePath = picturePath2,
                    Price       = price2,
                    StartTime   = startTime2,
                    Title       = title2,
                    UserId      = userId2
                }
            });

            var itemsService = new ItemsService(dataStoreMock.Object);

            // Act
            var result = itemsService.GetById(id2.ToString());

            // Assert
            Assert.IsNotNull(result, "result != null");
            Assert.AreEqual(description2, result.Description, "Incorrect Description returned");
            Assert.AreEqual(endTime2, result.EndTime, "Incorrect EndTime returned");
            Assert.AreEqual(id2.ToString(), result.Id, "Incorrect Id returned");
            Assert.AreEqual(price2, result.Price, "Incorrect Price returned");
            Assert.AreEqual(picturePath2, result.PicturePath, "Incorrect PicturePath returned");
            Assert.AreEqual(startTime2, result.StartTime, "Incorrect StartTime returned");
            Assert.AreEqual(title2, result.Title, "Incorrect Title returned");
        }
 // GET: items/Details/5
 public ActionResult Details(int id)
 {
     return(View(cos.GetById(id)));
 }