public static void editClass(int id, string class_name, string note , int?from_teacher_id, int?group_id) { using (var db = new ChurchModel()) { var edit_class = db.CLASSes.Where(m => m.class_id == id).FirstOrDefault(); edit_class.class_name = class_name; edit_class.note = note; edit_class.form_teacher_id = from_teacher_id; edit_class.group_id = group_id; db.Entry(edit_class).State = EntityState.Modified; var teacherbyid = db.USERLOGINs.Where(m => m.userid == from_teacher_id).FirstOrDefault(); var amountofteach = db.USERLOGINs.Where(m => m.userid == from_teacher_id && m.class_id == id).ToList().Count; if (amountofteach == 0) { teacherbyid.class_id = id; db.Entry(teacherbyid).State = EntityState.Modified; } db.SaveChanges(); db.Dispose(); } }
public static void addClass(string class_name, string note, int?from_teacher_id, int?group_id) { using (var db = new ChurchModel()) { int countclassitem = db.CLASSes.ToList().Count(); db.CLASSes.Add(new CLASS { class_id = countclassitem + 1, class_name = class_name, note = note, form_teacher_id = from_teacher_id, group_id = group_id, IsDeleted = false, IsActive = true }); if (from_teacher_id != null) { var teacherbyid = db.USERLOGINs.Where(m => m.userid == from_teacher_id).FirstOrDefault(); teacherbyid.class_id = countclassitem + 1; db.Entry(teacherbyid).State = EntityState.Modified; } db.SaveChanges(); db.Dispose(); } }
public static void editStudentinfo(int id, string holy_name, string first_name, string last_name, string email, string phone_number, string gender, string useradress, DateTime?birthday, DateTime?baptised_date, int?parish_id, string parish, string diocese, string provice) { using (var db = new ChurchModel()) { int count_user_parish = db.USER_PARISH_ROLE.Count(); var userbyid = db.USERLOGINs.Where(m => m.userid == id && m.isDeleted == false).FirstOrDefault(); userbyid.holy_name = holy_name; userbyid.first_name = first_name; userbyid.last_name = last_name; userbyid.email = email; userbyid.phone_number = phone_number; userbyid.gender = gender; userbyid.useradress = useradress; userbyid.birthday = birthday; userbyid.baptised_date = baptised_date; userbyid.parish = parish; userbyid.diocese = diocese; userbyid.province = provice; db.Entry(userbyid).State = EntityState.Modified; var user_parish_role = db.USER_PARISH_ROLE.Where(m => m.userid == id && m.roleid == 1).FirstOrDefault(); if (parish_id != null) { if (user_parish_role != null) { user_parish_role.parishid = parish_id; db.Entry(user_parish_role).State = EntityState.Modified; } else { db.USER_PARISH_ROLE.Add(new USER_PARISH_ROLE { USER_PARISH_ROLE_ID = count_user_parish + 1, roleid = 1, userid = userbyid.userid, parishid = parish_id, isDeleted = false }); } } db.SaveChanges(); db.Dispose(); } }
public static void deleteGroup(int id) { using (var db = new ChurchModel()) { var delete_group = db.LEARNING_GROUP.Where(m => m.group_id == id).FirstOrDefault(); delete_group.IsDeleted = true; db.Entry(delete_group).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }
public static void deleted_student(int id) { using (var db = new ChurchModel()) { var userbyid = db.USERLOGINs.Where(m => m.userid == id && m.isDeleted == false).FirstOrDefault(); userbyid.isDeleted = true; db.Entry(userbyid).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }
public static void deleteClass(int id) { using (var db = new ChurchModel()) { var delete_class = db.CLASSes.Where(m => m.class_id == id).FirstOrDefault(); delete_class.IsDeleted = true; db.Entry(delete_class).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }
public static void editStudentAttendClass(int id, int?class_id) { using (var db = new ChurchModel()) { int count_user_parish = db.USER_PARISH_ROLE.Count(); var userbyid = db.USERLOGINs.Where(m => m.userid == id && m.isDeleted == false).FirstOrDefault(); userbyid.class_id = class_id; db.Entry(userbyid).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }
public static void editGroup(int id, string group_name, string note , int?parish_id) { using (var db = new ChurchModel()) { var edit_group = db.LEARNING_GROUP.Where(m => m.group_id == id).FirstOrDefault(); edit_group.group_name = group_name; edit_group.note = note; edit_group.parishid = parish_id; db.Entry(edit_group).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }
public static void editStudent_parentInfo(int id, string father_name, string father_phone_number, string mother_name, string mother_phone_number) { using (var db = new ChurchModel()) { var userbyid = db.USERLOGINs.Where(m => m.userid == id && m.isDeleted == false).FirstOrDefault(); userbyid.father_name = father_name; userbyid.father_phone_number = father_phone_number; userbyid.mother_name = mother_name; userbyid.mother_phone_number = mother_phone_number; db.Entry(userbyid).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }
public static void editStudentSacramental(int id, string baptised_place, DateTime?baptised_date , string first_communion_place, DateTime?first_communion_date, string confirmation_place, DateTime?confirmation_date) { using (var db = new ChurchModel()) { var userbyid = db.USERLOGINs.Where(m => m.userid == id && m.isDeleted == false).FirstOrDefault(); userbyid.baptised_place = baptised_place; userbyid.baptised_date = baptised_date; userbyid.first_communion_place = first_communion_place; userbyid.first_communion_date = first_communion_date; userbyid.comfirmation_place = confirmation_place; userbyid.comfirmation_date = confirmation_date; db.Entry(userbyid).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); } }