Beispiel #1
0
 public bool UpdateShagrir(Shagrir shagrirToUpdate)
 {
     var shgs = dal.ReadShagrirs();
     if (!(shgs.Count(x =>
         x.Id == shagrirToUpdate.Id ||
         x.Name == shagrirToUpdate.Name ||
         x.Phone == shagrirToUpdate.Phone) == 1))
         throw new Exception("Cannot update shagrir");
     return dal.UpdateShagrir(shagrirToUpdate);
 }
Beispiel #2
0
 public bool AddShagrir(Shagrir shagrirToAdd)
 {
     var shgs = dal.ReadShagrirs();
     if (shgs.Count(x =>
         x.Id == shagrirToAdd.Id ||
         x.Name == shagrirToAdd.Name ||
         x.Phone == shagrirToAdd.Phone) > 0)
         throw new Exception("Shagrir Already Exist");
     return dal.CreateShagrir(shagrirToAdd);
 }
Beispiel #3
0
 private static void CopyShagrir(Shagrir shagrirToUpdate, ref Shagrir shag)
 {
     shag.Gender = shagrirToUpdate.Gender;
     shag.Address = shagrirToUpdate.Address;
     shag.BirthDate = shagrirToUpdate.BirthDate;
     shag.Candidates = shagrirToUpdate.Candidates;
     shag.Name = shagrirToUpdate.Name;
     shag.Phone = shagrirToUpdate.Phone;
     shag.Reputation = shagrirToUpdate.Reputation;
 }
Beispiel #4
0
 public bool DeleteShagrir(Shagrir shagrirToDelete)
 {
     var shag = contex.Shagrirs.FirstOrDefault<Shagrir>(x => x.Id == shagrirToDelete.Id);
     if (shag != null)
     {
         contex.Shagrirs.Remove(shag);
         return contex.SaveChanges() > 0;
     }
     else
         return false;
 }
Beispiel #5
0
 public bool UpdateShagrir(Shagrir shagrirToUpdate)
 {
     var shag = contex.Shagrirs.FirstOrDefault<Shagrir>(x => x.Id == shagrirToUpdate.Id);
     if (shag != null)
     {
         CopyShagrir(shagrirToUpdate, ref shag);
         return contex.SaveChanges() > 0;
     }
     else
         return false;
 }
Beispiel #6
0
 public bool AddShagrir(Shagrir shagrirToAdd)
 {
     return backend.AddShagrir(shagrirToAdd);
 }
Beispiel #7
0
 public bool CreateShagrir(Shagrir shagrirToCreate)
 {
     contex.Shagrirs.Add(shagrirToCreate);
     return contex.SaveChanges() > 0;
 }