Beispiel #1
0
        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();
        }
Beispiel #2
0
        public void CreateLection(LectionDTO lection)
        {
            Lection newLection = map.Map <Lection>(lection);

            db.Lections.Add(newLection);
            db.Save();
        }
Beispiel #3
0
        public LectionDTO GetByID(int lectionID)
        {
            Lection    lection = db.Lections.Get(lectionID);
            LectionDTO result  = map.Map <LectionDTO>(lection);

            return(result);
        }
Beispiel #4
0
        public void EditLection(LectionDTO lection)
        {
            Lection editedLection = db.Lections.Get(lection.LectionID);

            map.Map(lection, editedLection);
            db.Lections.Update(editedLection);
            db.Save();
        }
Beispiel #5
0
        public IHttpActionResult Delete(int id)
        {
            LectionDTO toDelete = _db.LectionService.GetByID(id);

            if (toDelete == null)
            {
                return(NotFound());
            }

            _db.LectionService.DeleteLection(toDelete);
            return(Ok(toDelete));
        }
Beispiel #6
0
 // 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));
 }
Beispiel #7
0
 public void DeleteLection(LectionDTO lection)
 {
     db.Lections.Delete(lection.LectionID);
     db.Save();
 }