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));
            }
        }