Ejemplo n.º 1
0
        public ActionResult <List <Place> > Get()
        {
            var temp = new List <Place>();

            foreach (IDBEntity e in _placeService.Get())
            {
                temp.Add(e as Place);
            }

            return(temp);
        }
Ejemplo n.º 2
0
        public void PlaceServiceGet_PlaceId_ReturnsPlaceDto()
        {
            // Arrange
            int placeId = 1;

            //var mapperMock = new Mock<IMappingAction<Place,PlaceDto>>();
            //var mapperMock2 = new Mock<IObjectMapper>();
            //var mapperMock2 = new Mock<IMapper>();
            //    mapperMock2.Setup(m => m.Map<Place, PlaceDto>(It.IsAny<Place>())).Returns(new PlaceDto());


            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(u => u.Places.Add(new Place {
                Id = 1, Name = "Kharkiv railway station"
            }));
            uowMock.Setup(u => u.Places.Get(placeId)).Returns(new Place {
                Name = "Kharkiv railway station"
            });

            var placeService = new PlaceService(uowMock.Object);


            // Act
            var placeDto = placeService.Get(placeId);

            // Assert
            //Assert.IsNotNull(placeDto);
            //uowMock.Verify(a => a.Places.Get(placeId), Times.Exactly(2));
            Assert.AreEqual("Kharkiv railway station", placeDto.Name);
        }
Ejemplo n.º 3
0
        //----------------------------------------------------------------------------------

        public ActionResult InformPlace(int id)
        {
            ViewBag.Page   = pageInfo.setView("InformPlace").setTitle("InformPlace");
            ViewBag.Method = HttpContext.Request.HttpMethod;

            PlaceDTO placeDTO = PlaceService.Get(id);

            if (placeDTO == null)
            {
                return(HttpNotFound());
            }
            List <PlacePhotoDTO> photo  = PlacePhotoServices.GetAll().Where(x => x.PlaceId == id).ToList();
            List <ReviewDTO>     review = ReviewServices.GetAll().Where(x => x.PlaceId == id).OrderByDescending(x => x.Date).ToList();

            //IQueryable<Rating> R = db.Ratings.Where(x => x.IdPlace == id);

            int RLike   = review.Count(x => x.ValueLike == 1);
            int RDis    = review.Count(x => x.ValueLike == 2);
            int RCheck  = review.Count(x => x.Checkin == 1);
            int RRating = (RLike + RDis == 0) ? 0 : Convert.ToInt32(Math.Round(10.0 * Convert.ToDouble(RLike) / Convert.ToDouble(RLike + RDis)));

            List <UserDTO> userDTO = UserServices.GetAll();


            PlaceDTO obj = new PlaceDTO()
            {
                Id          = placeDTO.Id,
                Name        = placeDTO.Name,
                Longitude   = placeDTO.Longitude,
                Latitude    = placeDTO.Latitude,
                Address     = placeDTO.Address,
                Description = placeDTO.Description,
                Phone       = placeDTO.Phone,

                Site        = placeDTO.Site,
                WorkingHour = placeDTO.WorkingHour
            };

            ViewBag.Album    = photo;
            ViewBag.Checkins = RCheck;
            ViewBag.Comments = review;
            ViewBag.Dislike  = RDis;
            ViewBag.Like     = RLike;
            ViewBag.Ratings  = RRating;
            ViewBag.Login    = userDTO;
            return(View(obj));
        }
Ejemplo n.º 4
0
 public ActionResult <List <Place> > Get()
 {
     return(_placeService.Get());
 }