/// <summary> /// delete collaborator from database /// </summary> /// <param name="id"></param> /// <returns></returns> public bool deleteCollaboratorConfirmed(int?id) { try { Colaborateur collaborator = db.Colaborateur.Find(id); DemandeVisa demandeVisa = (from v in db.DemandeVisa where v.IdC == id select v).FirstOrDefault(); if (demandeVisa != null) { demandeVisa.IdC = null; db.DemandeVisa.Remove(demandeVisa); } if (collaborator.IdD != null) { collaborator.IdD = null; db.Entry(collaborator).State = EntityState.Modified; } db.Colaborateur.Remove(collaborator); db.SaveChanges(); } catch (ArgumentNullException) { Log.Error("ArgumentNullException: id passed is null ,Colaborateur can not be found ..."); return(false); } catch (Exception e) { Log.Error(e.StackTrace); return(false); } return(true); }
/// <summary> /// add new request to database /// </summary> /// <param name="demandeVisa"></param> public void addRequestVisa(DemandeVisa demandeVisa) { try { db.DemandeVisa.Add(demandeVisa); Colaborateur c = db.Colaborateur.Find(demandeVisa.IdC); c.DateValiditeVisa = demandeVisa.DateValiditeVisa; c.DateFinVisa = demandeVisa.DateFinVisa; db.Entry(c).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { Log.Error(e.StackTrace); } }
/// <summary> /// edit displacement in database /// </summary> /// <param name="deplacement"></param> /// <param name="IdU"></param> public void editDisplacement(Deplacement deplacement, int? [] IdU) { try { col.addDisplacementToCollaborators(deplacement, IdU); db.Entry(deplacement).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { Log.Error(e.StackTrace); } }