public bool UpdateAdventure(AdventureEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Adventures .Single(e => e.AdventureId == model.AdventureId && e.OwnerId == _userId); entity.AdventureId = model.AdventureId; entity.Title = model.Title; entity.Description = model.Description; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(AdventureEdit adventure) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAdventureService(); if (!service.UpdateAdventure(adventure)) { return(InternalServerError()); } return(Ok()); }