Esempio n. 1
0
        public ActionResult <Work> ChangeLocation(int workID, int placeID)
        {
            User user = UserRep.FindByEmail(User.Identity.Name);

            UserRep.ClearCurrentPlaces(user);
            Place place = PlaceRep.Find(placeID);
            Work  work  = WorkRep.Find(workID);

            if (place == null || work == null || work.User != user)
            {
                return(new ForbidResult());
            }
            Facility facility = PlaceRep.FindFacilityByPlace(placeID);

            if (!facility.Workers.Contains(work))
            {
                return(new ForbidResult());
            }
            else
            {
                WorkRep.ChangeCurrentPlace(work, placeID);
                return(new ObjectResult(work));
            }
        }
        public ActionResult DeletePlace(int facilityID, int placeID)
        {
            User     user     = UserRep.FindByEmail(User.Identity.Name);
            Facility facility = FacilityRep.Find(facilityID);
            Place    place    = PlaceRep.Find(placeID);

            if (place.FacilityID != facilityID)
            {
                return(new ForbidResult());
            }
            else if (FacilityRep.IsAdmin(user, facility))
            {
                PlaceRep.Delete(placeID);
                return(Ok());
            }
            else
            {
                return(new ForbidResult());
            }
        }
 public async Task <IReadOnlyCollection <Place> > Get(string search)
 {
     return(await _placeRepository.Find(search, 15));
 }
Esempio n. 4
0
        public async Task FindsPlaceByNameStart()
        {
            // arrange
            string searchText = "Utr";

            // act
            var results = await _placeRepository.Find(searchText, 10);

            // assert
            Assert.That(results, Is.Not.Empty);
            Assert.That(results.First().Name, Is.EqualTo("Utrecht"));
        }