public static List <ProfessionalDTO> GetProfessionalList() { using (RecommendationsEntities3 db = new RecommendationsEntities3()) { return(ProfessionalConvertion.ProfessionalsListToDTO(db.Professionals.ToList())); } }
public static UsersDTO GetProfessionalById(int id) { using (RecommendationsEntities3 db = new RecommendationsEntities3()) { var p = db.Users.Find(id); if (p.Professionals != null) { return(ProfessionalConvertion.ProfessionalToDTO(p.Professionals)); } return(UsersConvertion.UserToDTO(p)); } }
public static bool RegisterProfessional(ProfessionalDTO professional)//??????profession { using (RecommendationsEntities3 db = new RecommendationsEntities3()) { if (professional.CityName != null) { professional.City = SetCityId(professional.CityName); } var prof = db.Professionals.Find(professional.ProfessionalId); var user = db.Users.Find(professional.UserId); //ProfessionsService.SetProfessionsToProfessional(professional);הוספת מקצועות לבעל מקצוע if (prof == null) { if (user == null) { db.Professionals.Add(ProfessionalConvertion.ProfessionalToDal(professional)); } else { db.Professionals.Add(ProfessionalConvertion.ProfessionalWithoutUserToDal(professional)); } } else { prof.FirstName = professional.FirstName; prof.LastName = professional.LastName; prof.BussName = professional.BussName; prof.NumHouse = professional.NumHouse; prof.Street = professional.Street; prof.DescriptionOn = professional.DescriptionOn; prof.Users.City = professional.City; prof.Users.IsManager = professional.IsManager; prof.Users.UserPassword = professional.UserPassword; prof.Users.UserPhone = professional.UserPhone; prof.Users.UserName = professional.UserName; //prof.ProfessionForProfessional.Add.AddRange(professional.professions.Select(p => new ProfessionForProfessional { Profession = p.ProfessionId, Professional = professional.UserId })); //לעשות הוספת מקצועות לבעל מקצוע בשתי האפשרויות :יצירה ועדכון } try { db.SaveChanges(); return(true); } catch { return(false); } } }