public static bool UpdatePatient(Patients patient) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { //יצירת רפרנס לאובייקט מהמסד נתונים Patients newp = db.Patients.Where(p => p.PatientId == patient.PatientId).FirstOrDefault(); if (patient.PatientTz != null && patient.PatientTz != "") { newp.PatientTz = patient.PatientTz; } if (patient.Firstname != null && patient.Firstname != "") { newp.Firstname = patient.Firstname; } if (patient.Lastname != null && patient.Lastname != "") { newp.Lastname = patient.Lastname; } if (patient.Password != null && patient.Password != "") { newp.Password = patient.Password; } if (patient.PhoneNumber1 != null && patient.PhoneNumber1 != "") { newp.PhoneNumber1 = patient.PhoneNumber1; } if (patient.PhoneNumber2 != null && patient.PhoneNumber2 != "") { newp.PhoneNumber2 = patient.PhoneNumber2; } if (patient.DateOfBirth != null) { newp.DateOfBirth = patient.DateOfBirth; } if (patient.Email != null && patient.Email != "") { newp.Email = patient.Email; } //newp.PatientTz = (patient.PatientTz != null && patient.PatientTz != "") ? patient.PatientTz: newp.PatientTz; //newp.Firstname = (patient.Firstname != null && patient.Firstname != "") ? patient.Firstname: newp.Firstname; //newp.Lastname = (patient.Lastname != null && patient.Lastname != "") ? patient.Lastname: newp.Lastname; //newp.Password = (patient.Password != null && patient.Password != "") ? patient.Password: newp.Password; //newp.PhoneNumber1 = (patient.PhoneNumber1 != null && patient.PhoneNumber1 != "") ? patient.PhoneNumber1: newp.PhoneNumber1; //newp.PhoneNumber2 = (patient.PhoneNumber2 != null && patient.PhoneNumber2 != "") ? patient.PhoneNumber2: newp.PhoneNumber2; //newp.DateOfBirth = (patient.DateOfBirth != null ) ? patient.DateOfBirth: newp.DateOfBirth; //newp.Email = (patient.Email != null && patient.Email != "") ? patient.Email: newp.Email; db.SaveChanges(); } } catch (Exception e) { return(false); } return(true); }
public static bool UpdatePatient(Therapists therapist) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { //יצירת רפרנס לאובייקט מהמסד נתונים //Therapists newt = db.Therapists.Where(t => t.TherapistId == therapist.TherapistId).FirstOrDefault(); Therapists newt = db.Therapists.Where(t => t.TherapistTz == therapist.TherapistTz).FirstOrDefault(); newt.TherapistTz = (therapist.TherapistTz != null && therapist.TherapistTz != "") ? therapist.TherapistTz: newt.TherapistTz; newt.FirstName = (therapist.FirstName != null && therapist.FirstName != "") ? therapist.FirstName: newt.FirstName; newt.LastName = (therapist.LastName != null && therapist.LastName != "") ? therapist.LastName: newt.LastName; newt.Password = (therapist.Password != null && therapist.Password != "") ? therapist.Password: newt.Password; newt.PhoneNumber = (therapist.PhoneNumber != null && therapist.PhoneNumber != "") ? therapist.PhoneNumber: newt.PhoneNumber; newt.DateOfBirth = (therapist.DateOfBirth != null) ? therapist.DateOfBirth: newt.DateOfBirth; newt.Email = (therapist.Email != null && therapist.Email != "") ? therapist.Email: newt.Email; newt.Image = (therapist.Image != null && therapist.Image != "") ? therapist.Image : newt.Image; newt.ServiceAreaId = (therapist.ServiceAreaId != null) ? therapist.ServiceAreaId : newt.ServiceAreaId; newt.Address = (therapist.Address != null && therapist.Address != "") ? therapist.Address : newt.Address; db.SaveChanges(); } } catch (Exception e) { return(false); } return(true); }
//GetById public static ServiceAreas GetById(int id) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { return(db.ServiceAreas.Find(id)); } } catch (Exception e) { return(null); } }
//GetById public static Applicants GetById(int id) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { return(db.Applicants.Find(id)); } } catch (Exception e) { return(null); } }
//GetByPatientId public static List <Meets> GetByPatientId(int p_id) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { return(db.Meets.Where(x => x.PatientId == p_id).ToList()); } } catch (Exception e) { return(null); } }
public static int[] GetCategoriesByTherapistId(int therapistId) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { int[] categories = db.Categories_Therapists.Where(c => c.TherapistId == therapistId).Select(c => c.CategotyId).ToArray(); return(categories); } } catch (Exception e) { return(null); } }
//GetAll public static List <Categories> GetAll() { try { using (Natural_wayEntities db = new Natural_wayEntities()) { List <Categories> lst = db.Categories.ToList(); return(lst); } } catch (Exception e) { return(null); } }
//GetAll public static List <Applicants> GetAllApplicants() { try { using (Natural_wayEntities db = new Natural_wayEntities()) { List <Applicants> lst = db.Applicants.ToList(); return(lst); } } catch (Exception e) { return(null); } }
//public static bool Login(string email, string pass) //{ // try // { // using (Natural_wayEntities db = new Natural_wayEntities()) // { // } // } //} //Get public static Patients GetById(int id) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { //where אפשר גם לפי return(db.Patients.Find(id)); } } catch (Exception e) { return(null); } }
public static Patients GetByEmail(string email) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { Patients p = db.Patients.Where(x => x.Email.Equals(email)).FirstOrDefault(); return(p); } } catch (Exception e) { Console.WriteLine(e.Message); return(null); } }
//Delete public static bool DeleteById(int id) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { db.Applicants.Remove(db.Applicants.Where(x => x.ApplicantId == id).FirstOrDefault()); db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
//Post-Add new public static bool AddServiceAreas(ServiceAreas s) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { db.ServiceAreas.Add(s); db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
//Post-Add new public static bool AddApplicant(Applicants a) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { db.Applicants.Add(a); db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
//Post-Add new public static bool AddWorkHours(WorkHours w) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { db.WorkHours.Add(w); db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
public static bool Register(Patients p) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { db.Patients.Add(p); db.SaveChanges(); } } catch (Exception e) { return(false); } return(true); }
//Post-Add new public static bool AddCategory(Categories c) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { db.Categories.Add(c); db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
public static string[] GetCategoriesNamesByTherapistId(int therapistId) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { int[] categories = GetCategoriesByTherapistId(therapistId); string[] categoriesNames = db.Categories.Where(c => categories.Contains(c.CategoryId)).Select(c => c.CategoryName).ToArray(); return(categoriesNames); } } catch (Exception e) { return(null); } }
//Delete public static bool DeleteById(int id) { try { using (Natural_wayEntities db = new Natural_wayEntities()) { //db.Entry(item).State = EntityState.Deleted; //pay <3!!! delete by id db.Meets.Remove(db.Meets.Where(x => x.MeetId == id).FirstOrDefault()); db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }