Beispiel #1
0
 bool UpdateCandidate(Candidate candidateToUpdate)
 {
     var cans = dal.ReadCandidates();
     if (!(cans.Count(x =>
         x.Id == candidateToUpdate.Id ||
         x.Name == candidateToUpdate.Name ||
         x.Phone == candidateToUpdate.Phone) == 1))
         throw new Exception("Cannot update candidate");
     return dal.UpdateCandidate(candidateToUpdate);
 }
Beispiel #2
0
 public bool AddCandidate(Candidate candidateToAdd)
 {
     var cans = dal.ReadCandidates();
     if (cans.Count(x =>
         x.Id == candidateToAdd.Id ||
         x.Name == candidateToAdd.Name ||
         x.Phone == candidateToAdd.Phone) > 0)
         throw new Exception("Candidate is already exist");
     return dal.CreateCandidate(candidateToAdd);
 }
Beispiel #3
0
 public bool UpdateCandidate(Candidate candidateToUpdate)
 {
     var can = contex.Candidates.FirstOrDefault<Candidate>(x => x.Id == candidateToUpdate.Id);
     if (can != null)
     {
         CopyCandidate(candidateToUpdate, ref can);
         return contex.SaveChanges() > 0;
     }
     else
         return false;
 }
Beispiel #4
0
 private static void CopyCandidate(Candidate candidateToUpdate, ref Candidate can)
 {
     can.Address = candidateToUpdate.Address;
     can.AgeRange = candidateToUpdate.AgeRange;
     can.BirthDate = candidateToUpdate.BirthDate;
     can.Employment = candidateToUpdate.Employment;
     can.Ethnical = candidateToUpdate.Ethnical;
     can.Gender = candidateToUpdate.Gender;
     can.Height = candidateToUpdate.Height;
     can.HighSchool = candidateToUpdate.HighSchool;
     can.Hobbies = candidateToUpdate.Hobbies;
     can.Info = candidateToUpdate.Info;
     can.LookingAppearance = candidateToUpdate.LookingAppearance;
     can.LookingNature = candidateToUpdate.LookingNature;
     can.More = candidateToUpdate.More;
     can.Name = candidateToUpdate.Name;
     can.Phone = candidateToUpdate.Phone;
     can.Pic1 = candidateToUpdate.Pic1;
     can.Pic2 = candidateToUpdate.Pic2;
     can.Sector = candidateToUpdate.Sector;
     can.Service = candidateToUpdate.Service;
     can.Shagrirs = candidateToUpdate.Shagrirs;
     can.ThirdParty = candidateToUpdate.ThirdParty;
 }
Beispiel #5
0
 public bool CreateCandidate(Candidate candidateToCreate)
 {
     contex.Candidates.Add(candidateToCreate);
     return contex.SaveChanges() > 0;
 }
Beispiel #6
0
 public bool DeleteCandidate(Candidate candidateToDelete)
 {
     var can = contex.Candidates.FirstOrDefault<Candidate>(x => x.Id == candidateToDelete.Id);
     if (can != null)
     {
         contex.Candidates.Remove(can);
         return contex.SaveChanges() > 0;
     }
     else
         return false;
 }