public void AddServices(servicesVM _servicesVM) { service serviceToAdd = new service(); serviceToAdd.service_id = _servicesVM.service_id; serviceToAdd.service_name = _servicesVM.service_name; MCDB.services.Add(serviceToAdd); MCDB.SaveChanges(); }
public void AddNewsType(newsTypeVM _newsTypeVM) { news_type newsTypeToAdd = new news_type(); newsTypeToAdd.type_id = _newsTypeVM.type_id; newsTypeToAdd.type_name = _newsTypeVM.type_name; MCDB.news_type.Add(newsTypeToAdd); MCDB.SaveChanges(); }
public void AddCategory(CategoryVM _catsVM) { courses_category categoryToAdd = new courses_category(); categoryToAdd.category_id = _catsVM.category_id; categoryToAdd.category_name = _catsVM.category_name; mcdb.courses_category.Add(categoryToAdd); mcdb.SaveChanges(); }
//adding a course public void AddQualification(qualificationVM _qualficVM) { qualification qualifcToAdd = new qualification(); qualifcToAdd.qualification_id = _qualficVM.qualification_id; qualifcToAdd.qualification_name = _qualficVM.qualification_name; qualifcToAdd.qualification_date = _qualficVM.qualification_date; qualifcToAdd.organization = _qualficVM.organization; MCDB.qualifications.Add(qualifcToAdd); MCDB.SaveChanges(); }
//adding a lab public void AddLab(labVM labVM) { lab labToAdd = new lab(); labToAdd.lab_name = labVM.lab_name; labToAdd.lab_number = labVM.lab_number; labToAdd.description = labVM.description; labToAdd.floor_number = labVM.floor_number; labToAdd.service_id = labVM.service_id; db.labs.Add(labToAdd); db.SaveChanges(); }
//adding a parenter public void AddParenter(parenterVM parentvm) { parenter parenterToAdd = new parenter(); parenterToAdd.email = parentvm.email; parenterToAdd.parenter_id = parentvm.parenter_id; parenterToAdd.Mobile = parentvm.Mobile; parenterToAdd.phone = parentvm.phone; parenterToAdd.parenter_name = parentvm.parenter_name; parenterToAdd.image = parentvm.image; db.parenters.Add(parenterToAdd); db.SaveChanges(); }
public void addAttendance(int courseid, int stuid) { //check if attendace already stored in db List <attendance> catt = MCDB.attendances.Where(x => DbFunctions.DiffDays(x.date, DateTime.Now) == 0 && x.course_id == courseid && x.user_id == stuid).ToList(); if (catt.Count == 0) { attendance attRec = new attendance(); attRec.course_id = courseid; attRec.user_id = stuid; attRec.date = DateTime.Now.Date; MCDB.attendances.Add(attRec); MCDB.SaveChanges(); } }
public bool AddUser(UsersVM userVM) { if (isValidUser(userVM.email, userVM.user_name)) { user_data userToAdd = new user_data(); userToAdd.user_name = userVM.user_name; userToAdd.address = userVM.address; userToAdd.age = userVM.age; userToAdd.email = userVM.email; userToAdd.national_id = userVM.national_id; userToAdd.phone = userVM.phone; userToAdd.role = userVM.role; userToAdd.qualification_id = userVM.qualification_id; userToAdd.loginUserName = userVM.loginUserName; userToAdd.password = userVM.password; userToAdd.qualification_id = userVM.qualification_id; MCDB.user_data.Add(userToAdd); MCDB.SaveChanges(); return(true); } else { return(false); } }
public void DeleteUser(int id) { using (MCenterDBContext db = new MCenterDBContext()) { user_data deletedIns = getUserByID(id); // db.instructors.Remove(deletedIns); db.Entry(deletedIns).State = EntityState.Deleted; db.SaveChanges(); } }
public static void UpdateInstructor(instructorQualificationPhoneViewModel instructorvm) { MCenterDBContext db = new MCenterDBContext(); instructor updataedInstructor = getInstructorByID(instructorvm.instructor_id); updataedInstructor.instructor_name = instructorvm.instructor_name; updataedInstructor.NameOf_ItsUnit = instructorvm.NameOf_ItsUnit; updataedInstructor.TrainningTopic = instructorvm.TrainningTopic; db.SaveChanges(); }
public static void AddInstructor(instructorQualificationPhoneViewModel instructorvm) { MCenterDBContext db = new MCenterDBContext(); instructor newInstructor = new instructor(); newInstructor.instructor_name = instructorvm.instructor_name; newInstructor.NameOf_ItsUnit = instructorvm.NameOf_ItsUnit; newInstructor.TrainningTopic = instructorvm.TrainningTopic; newInstructor.Current_JobTitle = instructorvm.Current_JobTitle; db.instructors.Add(newInstructor); db.SaveChanges(); instructor_phone newPhone = new instructor_phone(); newPhone.phone = instructorvm.phone; newPhone.instructor_id = newInstructor.instructor_id; db.instructor_phone.Add(newPhone); db.SaveChanges(); }
//adding a course public void AddCourse(CourseVM courseVM) { course courseToAdd = new course(); courseToAdd.course_name = courseVM.course_name; courseToAdd.appointments = courseVM.appointments; courseToAdd.description = courseVM.description; courseToAdd.hours_number = courseVM.hours_number; courseToAdd.price = courseVM.price; courseToAdd.starting_date = courseVM.starting_date; courseToAdd.category_id = courseVM.category_id; courseToAdd.instructor_id = courseVM.instructor_id; courseToAdd.isActive = courseVM.isActive; courseToAdd.service_id = courseVM.service_id; MCDB.courses.Add(courseToAdd); MCDB.SaveChanges(); }
public static void DeletePhoneInstructor(int insid) { MCenterDBContext db = new MCenterDBContext(); List <instructor_phone> instructor_Phones = db.instructor_phone.Where(x => x.instructor_id == insid).ToList(); foreach (var item in instructor_Phones) { db.instructor_phone.Remove(item); db.SaveChanges(); } }
public static void UpdateInstructor(instructorVM instructorvm) { using (MCenterDBContext db = new MCenterDBContext()) { instructor updataedInstructor = getInstructorByID(instructorvm.instructor_id); updataedInstructor.instructor_name = instructorvm.instructor_name; updataedInstructor.NameOf_ItsUnit = instructorvm.NameOf_ItsUnit; updataedInstructor.TrainningTopic = instructorvm.TrainningTopic; updataedInstructor.Current_JobTitle = instructorvm.Current_JobTitle; updataedInstructor.Mobile = instructorvm.Mobile; updataedInstructor.phone = instructorvm.phone; updataedInstructor.Email = instructorvm.Email; updataedInstructor.QualificationsName = instructorvm.QualificationsName; db.Entry(updataedInstructor).State = EntityState.Modified; db.SaveChanges(); } }
public static void AddInstructor(instructorVM instructorvm) { using (MCenterDBContext db = new MCenterDBContext()) { instructor newInstructor = new instructor(); newInstructor.instructor_name = instructorvm.instructor_name; newInstructor.NameOf_ItsUnit = instructorvm.NameOf_ItsUnit; newInstructor.TrainningTopic = instructorvm.TrainningTopic; newInstructor.Current_JobTitle = instructorvm.Current_JobTitle; newInstructor.Mobile = instructorvm.Mobile; newInstructor.phone = instructorvm.phone; newInstructor.Email = instructorvm.Email; newInstructor.QualificationsName = instructorvm.QualificationsName; db.instructors.Add(newInstructor); db.SaveChanges(); } }
public bool RegisterThisCourse(int courseId, int userId) { user_course userCourse = new user_course(); userCourse.course_id = courseId; userCourse.user_id = userId; if (!isRegistered(courseId, userId)) { MCDB.user_course.Add(userCourse); MCDB.SaveChanges(); return(true); } else { return(false); } }
public void UpdateUser(UsersVM userVm) { using (MCenterDBContext db = new MCenterDBContext()) { user_data updataedUser = getUserByID(userVm.user_id); updataedUser.user_name = userVm.user_name; updataedUser.age = userVm.age; updataedUser.email = userVm.email; updataedUser.national_id = userVm.national_id; updataedUser.address = userVm.address; updataedUser.phone = userVm.phone; updataedUser.qualification_id = userVm.qualification_id; updataedUser.loginUserName = userVm.loginUserName; updataedUser.password = userVm.password; db.Entry(updataedUser).State = EntityState.Modified; db.SaveChanges(); } }