public static Matchmaker RegisterMatchmaker(Matchmaker matchmaker) { try { var role = db.roles.First(p => p.Name == "MatchMarker"); var roleDto = Converters.Convert(role); matchmaker.Worker.User.Roles = new List <Role>(); matchmaker.Worker.User.Roles.Add(roleDto); var user = UserBL.Register(matchmaker.Worker.User); matchmaker.Worker.UserId = user.Id; matchmaker.Worker.User = null; matchmaker.Worker.CreateDate = DateTime.Now; matchmaker.Worker.UpdateDate = DateTime.Now; var matchmakerDB = Converters.Convert(matchmaker); matchmakerDB.worker.bank = null; matchmakerDB.worker.BankId = null; var matchmakerInter = db.matchmakers.Add(matchmakerDB); db.SaveChanges(); return(Converters.Convert(matchmakerInter)); } catch (Exception ex) { return(null); } }
public static List <Candidate> GetAllCandidate() { List <DTO.Candidate> AllCandidate = new List <Candidate>(); foreach (var item in db.candidates) { AllCandidate.Add(Converters.Convert(item)); } return(AllCandidate); }
public static List <Contactus> GetContactsStatus(int status) { try { return(Converters.Convert(db.contactus.Where(p => p.Status == status).OrderBy(p => p.UpdateDate).ToList())); } catch (Exception ex) { return(null); } }
public static List <Contactus> GetContacts() { try { return(Converters.Convert(db.contactus.OrderBy(p => p.UpdateDate).ToList())); } catch (Exception ex) { return(null); } }
public static List <DTO.MatchingHelper> GetAllMatching(int userId) { List <MatchingHelper> listMatchingHelper = new List <MatchingHelper>(); var helper = db.helpers.First(m => m.worker.UserId == userId); var matchinghelper = db.matchingHelpers.Where(m => m.HelperId == helper.Id); foreach (var item in matchinghelper) { var matchinghelperconvert = Converters.Convert(item); listMatchingHelper.Add(matchinghelperconvert); } return(listMatchingHelper); }
public static bool AddContactUs(Contactus contactus) { try { DAL.contactu c = Converters.Convert(contactus); c.CreateDate = DateTime.Now; c.UpdateDate = DateTime.Now; c.user = null; db.contactus.Add(c); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public static List <DTO.MatchingHelper> GetImportentMatching(int userId) { List <MatchingHelper> listImportentMatchingHelper = new List <MatchingHelper>(); var helper = db.helpers.First(m => m.worker.UserId == userId); var matchinghelper = db.matchingHelpers.Where(m => m.HelperId == helper.Id); foreach (var item in matchinghelper) { var matchinghelperconvert = Converters.Convert(item); listImportentMatchingHelper.Add(matchinghelperconvert); } listImportentMatchingHelper.Sort((x, y) => y.UpdateDate.CompareTo(x.UpdateDate)); return(listImportentMatchingHelper); }
public static List <Candidate> GetAllSearchCandidate(Candidate candidate) { List <DTO.Candidate> list = new List <Candidate>(); foreach (var item in db.candidates) { list.Add(Converters.Convert(item)); } if (candidate.SectorId != null) { list = list.Where(r => r.SectorId == candidate.SectorId).ToList(); } if (candidate.Gender != null) { list = list.Where(r => r.Gender == candidate.Gender).ToList(); } if (candidate.Status != null) { list = list.Where(r => r.Status == candidate.Status).ToList(); } if (candidate.Clothes != null) { list = list.Where(r => r.Clothes == candidate.Clothes).ToList(); } if (candidate.MedicalProblem != null) { list = list.Where(r => r.MedicalProblem == candidate.MedicalProblem).ToList(); } if (candidate.WhoMoneyAnother != null) { list = list.Where(r => r.WhoMoneyAnother <= candidate.WhoMoneyAnother).ToList(); } if (candidate.WhoMoneyGive != null) { list = list.Where(r => r.WhoMoneyGive <= candidate.WhoMoneyGive).ToList(); } if (candidate.Heigth != null) { list = list.Where(r => r.Heigth <= candidate.Heigth).ToList(); } return(list); }
public static List <Sector> GetSector() { try { List <Sector> c = new List <Sector>(); foreach (var item in db.sectors) { var sectorDB = Converters.Convert(item); c.Add(sectorDB); } return(c); } catch (Exception ex) { return(null); } }
public static List <City> GetCity() { try { List <City> c = new List <City>(); foreach (var item in db.cities) { var cityDB = Converters.Convert(item); c.Add(cityDB); } return(c); } catch (Exception ex) { return(null); } }
public static Helper RegisterHelper(Helper helper) { try { var role = db.roles.First(p => p.Name == "Worker"); var roleDto = Converters.Convert(role); helper.Worker.User.Roles.Add(roleDto); var user = UserBL.Register(helper.Worker.User); helper.Worker.UserId = user.Id; var helperDB = Converters.Convert(helper); var helperInter = db.helpers.Add(helperDB); db.SaveChanges(); return(Converters.Convert(helperInter)); } catch (Exception ex) { return(null); } }
public static List <Chasidut> Getchasidut() { try { List <Chasidut> c = new List <Chasidut>(); foreach (var item in db.chasiduts) { var chasidutDB = Converters.Convert(item); c.Add(chasidutDB); } return(c); } catch (Exception ex) { return(null); } }
public static User Register(User user) { try { CreatePasswordHash(user.Password, out byte[] passwordHash, out byte[] passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; user.CreationDate = DateTime.Now; var userDB = Converters.Convert(user); var role = db.roles.Find(userDB.roles.FirstOrDefault().Id); userDB.roles = new List <DAL.role>(); userDB.roles.Add(role); var userInter = db.users.Add(userDB); db.SaveChanges(); return(Converters.Convert(userInter)); } catch (Exception ex) { return(null); } }
public static List <Candidate> CandidatesPersonalCare(int IdMatchmaker) { List <DTO.Candidate> AllCandidate = new List <Candidate>(); List <DTO.Candidate> CandidatesPersonalCare = new List <Candidate>(); foreach (var item in db.candidates) { //{if(item.matchings.candidateid==) AllCandidate.Add(Converters.Convert(item)); } foreach (var item in AllCandidate) { Random rnd = new Random(); int num = rnd.Next(AllCandidate.Count); CandidatesPersonalCare.Add(AllCandidate[num]); AllCandidate[num].Status = 1; } return(AllCandidate); }
public static Candidate RegisterCandidate(Candidate candidate) { using (TransactionScope transaction = new TransactionScope()) { try { candidate.CreateDate = DateTime.Now; candidate.UpdateDate = DateTime.Now; var candidateDB = Converters.Convert(candidate); var canInfo = candidateDB.infoCandidates; var canFamily = candidateDB.candidateFamilies; var marrieds = candidateDB.marrieds; var user = candidateDB.user; var entryBy = candidateDB.user1; candidateDB.infoCandidates = null; candidateDB.candidateFamilies = null; candidateDB.marrieds = null; candidateDB.user = null; candidateDB.EntryByUser = null; candidateDB.chasidut = null; if (candidateDB.ChasidutId == 0) { candidateDB.ChasidutId = null; } if (candidateDB.MatchmarkerId == 0) { candidateDB.MatchmarkerId = null; candidateDB.matchmaker = null; } user.IsOk = true; var userIns = db.users.Add(user); db.SaveChanges(); candidateDB.UserId = userIns.Id; var candidateInter = db.candidates.Add(candidateDB); db.SaveChanges(); //if(entryBy!=null) //{ // db.users.Add(entryBy); // db.SaveChanges(); //} if (canInfo != null) { foreach (var item in canInfo) { item.CandidateId = candidateInter.Id; db.infoCandidates.Add(item); db.SaveChanges(); } } if (canFamily != null) { foreach (var item in canFamily) { item.CandidateId = candidateInter.Id; item.CreationDate = DateTime.Now; db.candidateFamilies.Add(item); db.SaveChanges(); } } if (marrieds != null) { foreach (var item in marrieds) { item.CandidateId = candidateInter.Id; db.marrieds.Add(item); db.SaveChanges(); } } transaction.Complete(); return(Converters.Convert(candidateInter)); } catch (Exception ex) { return(null); } } }