public void AddProgramCourse(ProgramCourses programCourses)
 {
     using (var context = new StarTEDContext())
     {
         context.ProgramCourses.Add(programCourses);
         context.SaveChanges();
     }
 }
 public void AddCourse(Courses course)
 {
     using (var context = new StarTEDContext())
     {
         context.Courses.Add(course);
         context.SaveChanges();
     }
 }
Example #3
0
 public int Rentals_Add(Rentals item)
 {
     using (var context = new StarTEDContext())
     {
         context.Rentals.Add(item);
         context.SaveChanges();
         return(item.RentalID);
     }
 }
Example #4
0
 public void DeleteClubActivity(int id)
 {
     using (var context = new StarTEDContext())
     {
         var exisiting = context.ClubActivities.Find(id);
         context.ClubActivities.Remove(exisiting);
         context.SaveChanges();
     }
 }
Example #5
0
 public void UpdateClubActivity(ClubActivity item)
 {
     using (var context = new StarTEDContext())
     {
         var exisiting = context.Entry(item);
         exisiting.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #6
0
 public int AddClubActivity(ClubActivity item)
 {
     using (var context = new StarTEDContext())
     {
         ClubActivity addeditem = context.ClubActivities.Add(item);
         context.SaveChanges();
         return(addeditem.ActivityID);
     }
 }
Example #7
0
 public int Rentals_Update(Rentals item)
 {
     using (var context = new StarTEDContext())
     {
         //Staging
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         //Commit and Feedback (rows affected)
         return(context.SaveChanges());
     }
 }
 public void RemoveCourse(Courses course)
 {
     using (var context = new StarTEDContext())
     {
         var entity = context.Courses.Where(t => t.CourseID == course.CourseID).FirstOrDefault();
         if (entity == null)
         {
             return;
         }
         context.Courses.Remove(entity);
         context.SaveChanges();
     }
 }
 public void RemoveProgramCourse(ProgramCourses programCourses)
 {
     using (var context = new StarTEDContext())
     {
         var id     = programCourses.ProgramCourseID;
         var entity = context.ProgramCourses.Where(t => t.ProgramCourseID == id).FirstOrDefault();
         if (entity == null)
         {
             return;
         }
         context.ProgramCourses.Remove(entity);
         context.SaveChanges();
     }
 }
        public void UpdateCourse(Courses course)
        {
            using (var context = new StarTEDContext())
            {
                var entity = context.Courses.Where(t => t.CourseID == course.CourseID).FirstOrDefault();
                if (entity == null)
                {
                    return;
                }
                entity.CourseName  = course.CourseName;
                entity.Credits     = course.Credits;
                entity.Description = course.Description;
                entity.Term        = course.Term;
                entity.TotalHours  = course.TotalHours;
                entity.Tuition     = course.Tuition;

                context.SaveChanges();
            }
        }
 public void UpdateProgramCourse(ProgramCourses programCourse)
 {
     using (var context = new StarTEDContext())
     {
         var entity = context.ProgramCourses.Where(t => t.ProgramCourseID == programCourse.ProgramCourseID).FirstOrDefault();
         if (entity == null)
         {
             return;
         }
         entity.Active          = programCourse.Active;
         entity.Comments        = programCourse.Comments;
         entity.CourseID        = programCourse.CourseID;
         entity.ProgramCourseID = programCourse.ProgramCourseID;
         entity.ProgramID       = programCourse.ProgramID;
         entity.Required        = programCourse.Required;
         entity.SectionLimit    = programCourse.SectionLimit;
         context.SaveChanges();
     }
 }
Example #12
0
        public int Rentals_Delete(int productid)
        {
            using (var context = new StarTEDContext())
            {
                //Physical Delete
                //the physical removal of a record from the database

                ////locate the instance of the entity to be removed
                var existing = context.Rentals.Find(productid);
                ////optional check to see if it is there
                ////if not throw an exception.
                ////this process can also be handled on the web form during feedback
                if (existing == null)
                {
                    throw new Exception("Record has already been removed from database");
                }

                ////Stage
                context.Rentals.Remove(existing);
                ////Commmit and feedback
                return(context.SaveChanges());
            }
        }