public void DeleteScheduledLection(LectionDTO lection, CourseDTO course) { ScheduledEvent scheduledLection = db.ScheduledEvents.Find(x => x.Lection.LectionID == lection.LectionID && x.Course.CourseID == course.CourseID).FirstOrDefault(); db.ScheduledEvents.Delete(scheduledLection.ScheduledEventID); db.Save(); }
public void CreateLection(LectionDTO lection) { Lection newLection = map.Map <Lection>(lection); db.Lections.Add(newLection); db.Save(); }
public LectionDTO GetByID(int lectionID) { Lection lection = db.Lections.Get(lectionID); LectionDTO result = map.Map <LectionDTO>(lection); return(result); }
public void EditLection(LectionDTO lection) { Lection editedLection = db.Lections.Get(lection.LectionID); map.Map(lection, editedLection); db.Lections.Update(editedLection); db.Save(); }
public IHttpActionResult Delete(int id) { LectionDTO toDelete = _db.LectionService.GetByID(id); if (toDelete == null) { return(NotFound()); } _db.LectionService.DeleteLection(toDelete); return(Ok(toDelete)); }
// PUT: api/Lections/5 public IHttpActionResult Put(int id, LectionModel value) { if (id != value.LectionID) { return(BadRequest()); } try { LectionDTO edited = map.Map <LectionDTO>(value); _db.LectionService.EditLection(edited); } catch { if (!LectionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void DeleteLection(LectionDTO lection) { db.Lections.Delete(lection.LectionID); db.Save(); }