private void Setup() { var pois = new List <PointOfInterest>(); var user = new User() { Id = "1", UserName = "******", Email = "*****@*****.**", DisplayName = "Administrator" }; var b = new BusinessHours { FromHour = new TimeSpan(9, 0, 0), ToHour = new TimeSpan(17, 59, 59) }; var p = new PointOfInterest(location, "Teste 1", b, 1, user); p.Id = 1; p.Approve(); pois.Add(p); pois.Add(new PointOfInterest(location, "Teste 2", b, 1, user) { Id = 2 }); p = new PointOfInterest(location, "Teste 3", b, 1, user); p.Id = 3; p.Approve(); pois.Add(p); pois.Add(new PointOfInterest(location, "Teste 4", b, 1, user) { Id = 4 }); this.pointsOfInterest = pois.AsQueryable(); }
public IHttpActionResult Approve(int id) { PointOfInterest p = unitOfWork.PoiRepository.Find(x => x.Id == id, null, "Location,Location.Coordinates").FirstOrDefault(); if (p == null) { return(NotFound()); } if (p.Status == Status.Approved) { return(StatusCode(HttpStatusCode.NoContent)); } p.Approve(); unitOfWork.PoiRepository.Update(p); unitOfWork.SaveChanges(); PoiViewModel vm = Mapper.Map <PoiViewModel>(p); return(Ok(vm)); }