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); }
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); }
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; }
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; }
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; }
public bool AddShagrir(Shagrir shagrirToAdd) { return backend.AddShagrir(shagrirToAdd); }
public bool CreateShagrir(Shagrir shagrirToCreate) { contex.Shagrirs.Add(shagrirToCreate); return contex.SaveChanges() > 0; }