public IHttpActionResult PutEventParticipatns(int id, EventParticipatns eventParticipatns) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eventParticipatns.EventParticipantsID) { return(BadRequest("Nije dan valjan ID")); } db.Entry(eventParticipatns).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EventParticipatnsExists(id)) { return(NotFound()); } else { throw; } } return(Ok()); }
public IHttpActionResult DeleteEventParticipatns(int id) { bool oldValidateOnSaveEnabled = db.Configuration.ValidateOnSaveEnabled; try { db.Configuration.ValidateOnSaveEnabled = false; var eventParticipant = new EventParticipatns { EventParticipantsID = id }; db.EventParticipatns.Attach(eventParticipant); db.Entry(eventParticipant).State = EntityState.Deleted; db.SaveChanges(); return(Ok("Izbrisan je event participant sa ovim ID-em: " + eventParticipant.EventParticipantsID)); } catch (Exception e) { return(BadRequest("Ne postoji to nešto sa ovim ID-em, kaj god ne da mi se više")); } finally { db.Configuration.ValidateOnSaveEnabled = oldValidateOnSaveEnabled; } }
public IHttpActionResult PostEventParticipatns(EventParticipatns eventParticipatns) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EventParticipatns.Add(new EventParticipatns() { CityID = eventParticipatns.EventID, EventID = eventParticipatns.EventID }); db.SaveChanges(); return(Ok()); }