/// <summary> /// add new displacement to database /// </summary> /// <param name="deplacement"></param> /// <param name="IdU"></param> public void addDisplacement(Deplacement deplacement, int?[] IdU) { try { db.Deplacement.Add(deplacement); db.SaveChanges(); col.addDisplacementToCollaborators(deplacement, IdU); } catch (Exception e) { Log.Error(e.StackTrace); } }
/// <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> /// add displacement to collaborators /// </summary> /// <param name="deplacement"></param> /// <param name="IdU"></param> public void addDisplacementToCollaborators(Deplacement deplacement, int?[] IdU) { try { if (IdU != null) { for (int i = 0; i < IdU.Length; i++) { Colaborateur colabo = db.Colaborateur.Find(IdU[i]); colabo.IdD = deplacement.Id; colabo.NombreDeplacement++; db.SaveChanges(); } } } catch (Exception e) { Log.Error("addDisplacementToCollaborators failed " + e.StackTrace); } }
public void AddColaborateur(Colaborateur colaborateur) { db.Colaborateur.Add(colaborateur); db.SaveChanges(); }