public ActionResult <List <Place> > Get() { var temp = new List <Place>(); foreach (IDBEntity e in _placeService.Get()) { temp.Add(e as Place); } return(temp); }
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); }
//---------------------------------------------------------------------------------- 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)); }
public ActionResult <List <Place> > Get() { return(_placeService.Get()); }