Beispiel #1
0
        public ActionResult AccountList(string type)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService EmpService  = new EmployeService(UOW);
                    RoleService    RoleService = new RoleService(UOW);


                    var Roles = RoleService.GetAll();
                    ViewBag.RoleList = new SelectList(Roles, "RoleId", "role");

                    if (type == "0")
                    {
                        return(View(EmpService.GetAll()));
                    }
                    else if (type == "1")
                    {
                        return(View(EmpService.GetEmployeByVerified(true)));
                    }
                    else if (type == "2")
                    {
                        return(View(EmpService.GetEmployeByVerified(false)));
                    }
                    else
                    {
                        return(View(EmpService.GetAll()));
                    }
                }
            }
        }
Beispiel #2
0
        //INSERT LIVRAISON
        public ActionResult Livraison(int empStock, int employe, int quantite,
                                      int resteNonVendu, string dateLivraison, int pointDeVente)
        {
            //Insertion livraison

            livraisonCarteService = new LivraisonCarteService();
            empStockService       = new EmployeStockService();
            empService            = new EmployeService();

            Employe        emp          = new Employe(employe);
            PointDeVente   pointVente   = new PointDeVente(pointDeVente);
            EmployeStock   employeStock = new EmployeStock(empStock);
            DateTime       date         = DateTime.Parse(dateLivraison);
            LivraisonCarte livCarte     = new LivraisonCarte(employeStock, quantite, resteNonVendu,
                                                             date, pointVente);

            livraisonCarteService.insert(livCarte);

            //Update stock
            EmployeStockVue emplStock = empStockService.findById(empStock);

            Debug.WriteLine("Emp stock update " + emplStock.Stock + "-" + empStock);
            int          stockUpdate    = emplStock.Stock - quantite;
            EmployeStock empStockUpdate = new EmployeStock(emplStock.Id, stockUpdate);

            empStockService.update(empStockUpdate);

            //GET ALL STOCK

            EmployeVue             empl    = empService.findById(employe);
            List <EmployeStockVue> listAll = empStockService.search(new EmployeStockVue(empl.Nom, emp.Prenom));

            ViewBag.listStock = listAll;
            return(View());
        }
Beispiel #3
0
        public void GetListEmployesTest()
        {
            var entrepriseService = new EmployeService(new MockStorage());
            var employes          = entrepriseService.GetListEmployes();

            Assert.AreEqual(employes.Count, 2);
        }
Beispiel #4
0
        public ActionResult ChangePassword(CompteConfigViewModel CompteCVM)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    RoleService    RoleService = new RoleService(UOW);
                    EmployeService EmpService  = new EmployeService(UOW);

                    Employe e = EmpService.GetEmployeByUername(Session["username"].ToString());

                    if (e.Password == CompteCVM.Password)
                    {
                        e.Password        = CompteCVM.NewPassword;
                        e.ConfirmPassword = CompteCVM.NewPassword;

                        EmpService.Update(e);
                        EmpService.Commit();
                    }
                    else
                    {
                        ModelState.AddModelError("Password", "Votre mot de passe actuel est incorrect");
                    }

                    return(View());
                }
            }
        }
Beispiel #5
0
        public ActionResult InscriptionCompte(Employe emp)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    RoleService    RoleService = new RoleService(UOW);
                    EmployeService EmpService  = new EmployeService(UOW);

                    var Roles = RoleService.GetAll();
                    ViewBag.RoleList = new SelectList(Roles, "RoleId", "role");

                    if (EmpService.GetEmployeByUername(emp.Username) != null)
                    {
                        ModelState.AddModelError("Username", "Nom d'utilisateur existe deja !");
                    }
                    else
                    {
                        EmpService.Add(emp);
                        EmpService.Commit();
                        return(RedirectToAction("Login"));
                    }

                    //Response.Write("<script>alert('" + emp.RoleId + "')</script>");
                    return(View());
                }
            }
        }
        public ActionResult mensuelStatTraite(string year, string month)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    EmployeService     EmpService         = new EmployeService(UOW);

                    int mensuelPoste1Tot = 0;
                    int mensuelPoste2Tot = 0;
                    int mensuelPoste3Tot = 0;
                    int mensuelPoste4Tot = 0;
                    int tot = 0;

                    double mensuelRentaPoste1Tot = 0;
                    double mensuelRentaPoste2Tot = 0;
                    double mensuelRentaPoste3Tot = 0;
                    double mensuelRentaPoste4Tot = 0;
                    double totRenta = 0;
                    List <ClientAffecteViewModel> JoinedList = new List <ClientAffecteViewModel>();

                    JoinedList = (from f in FormulaireService.GetAll()
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId

                                  select new ClientAffecteViewModel
                    {
                        Formulaire = f,
                        Affectation = a,
                        Lot = l,
                    }).ToList();



                    if (month != "" && year != "" && month != null && year != null)
                    {
                        mensuelPoste1Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE1" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        mensuelPoste2Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE2" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        mensuelPoste3Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE3" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        mensuelPoste4Tot = JoinedList.Where(j => j.Affectation.Employe.Username == "POSTE4" && j.Formulaire.TraiteLe.Date.Year + "" == year && j.Formulaire.TraiteLe.Date.Month + "" == month).Count();
                        tot = mensuelPoste1Tot + mensuelPoste2Tot + mensuelPoste3Tot + mensuelPoste4Tot;

                        mensuelRentaPoste1Tot = rentabiliteAgents(year, month, "POSTE1", LotService, FormulaireService, AffectationService);
                        mensuelRentaPoste2Tot = rentabiliteAgents(year, month, "POSTE2", LotService, FormulaireService, AffectationService);
                        mensuelRentaPoste3Tot = rentabiliteAgents(year, month, "POSTE3", LotService, FormulaireService, AffectationService);
                        mensuelRentaPoste4Tot = rentabiliteAgents(year, month, "POSTE4", LotService, FormulaireService, AffectationService);
                        totRenta = mensuelRentaPoste1Tot + mensuelRentaPoste2Tot + mensuelRentaPoste3Tot + mensuelRentaPoste4Tot;
                    }


                    return(Json(new { tot = tot, mensuelPoste1Tot = mensuelPoste1Tot, mensuelPoste2Tot = mensuelPoste2Tot, mensuelPoste3Tot = mensuelPoste3Tot, mensuelPoste4Tot = mensuelPoste4Tot, totRenta = String.Format("{0:0.00}", totRenta), mensuelRentaPoste1Tot = mensuelRentaPoste1Tot, mensuelRentaPoste2Tot = mensuelRentaPoste2Tot, mensuelRentaPoste3Tot = mensuelRentaPoste3Tot, mensuelRentaPoste4Tot = mensuelRentaPoste4Tot }));
                }
            }
        }
        protected override void OnInitialized()
        {
            base.OnInitialized();
            var employee = EmployeService.GetEmployee(1);

            Id      = employee.Id;
            Name    = employee.Name;
            Dept    = employee.Dept;
            Address = employee.Address;
        }
 public AddWorkDoneForm(ApplicationDbContext context)
 {
     dbContext         = context;
     subjectService    = new SubjectService(dbContext);
     solidWasteService = new SolidWasteService(dbContext);
     argumentService   = new ArgumentService(dbContext);
     collectService    = new CollectService(dbContext);
     employeService    = new EmployeService(dbContext);
     InitializeComponent();
 }
Beispiel #9
0
        public ActionResult UpdateAccount(int id)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService EmpService  = new EmployeService(UOW);
                    RoleService    RoleService = new RoleService(UOW);

                    var Roles = RoleService.GetAll();
                    ViewBag.RoleList = new SelectList(Roles, "RoleId", "role");

                    return(View(EmpService.GetById(id)));
                }
            }
        }
Beispiel #10
0
        //
        // GET: /Accueil/


        public ActionResult Index(string id, string utilisateur)
        {
            distribCarteService = new DistributionCarteService();
            carteService        = new CarteService();
            empService          = new EmployeService();
            typeEmployeService  = new TypeEmployeService();
            List <DistributionCarteVue> listCarteDistribue = distribCarteService.getAll();
            List <Carte>      listCarte = carteService.getAll();
            TypeEmploye       typEmp    = typeEmployeService.findById(3);
            Employe           emp       = new Employe(typEmp);
            List <EmployeVue> listEmp   = new EmployeDAO().search(emp);

            ViewBag.ListeCarteDistr = listCarteDistribue;
            ViewBag.ListeCarte      = listCarte;
            ViewBag.ListEmp         = listEmp;
            return(View());
        }
Beispiel #11
0
        public ActionResult Index(int id)
        {
            empStockService     = new EmployeStockService();
            empService          = new EmployeService();
            pointDeVenteService = new PointDeVenteService();

            List <EmployeVue>      listEmploye      = empService.getAll();
            List <PointDeVenteVue> listPointDeVente = pointDeVenteService.getAll();

            ViewBag.listEmploye    = listEmploye;
            ViewBag.listPointVente = listPointDeVente;

            EmployeVue             emp     = empService.findById(id);
            List <EmployeStockVue> listAll = empStockService.search(new EmployeStockVue(emp.Nom, emp.Prenom));

            ViewBag.listStock = listAll;
            return(View());
        }
Beispiel #12
0
        public IEnumerable <SelectListItem> AgentListForDropDown(EmployeService EmpService)
        {
            List <Employe>        agents    = EmpService.GetMany(emp => emp.Role.role.Equals("agent") && emp.IsVerified == true).ToList();
            List <SelectListItem> listItems = new List <SelectListItem>();

            listItems.Add(new SelectListItem {
                Selected = true, Text = "Tous les agents", Value = "0"
            });

            agents.ForEach(l =>
            {
                listItems.Add(new SelectListItem {
                    Text = l.Username, Value = l.EmployeId + ""
                });
            });

            return(listItems);
        }
Beispiel #13
0
        // Add card
        public ActionResult InsertCard(int carte, int employe, int quantite, string date)
        {
            //instanciation des services
            distribCarteService      = new DistributionCarteService();
            empStockService          = new EmployeStockService();
            empService               = new EmployeService();
            carteService             = new CarteService();
            employeStockHistoService = new EmployeStockHistoService();

            //instanciation objet depuis argument
            Carte      c        = new Carte(carte);
            Employe    emp      = new Employe(employe);
            DateTime   dateTime = DateTime.Parse(date);
            EmployeVue employee = empService.findById(employe);
            Carte      cartee   = carteService.findById(carte);

            //instanciation distribution carte
            DistributionCarte carteDist = new DistributionCarte(c, emp, quantite, dateTime);

            //Recherche du stock de l'employe actuelle
            EmployeStockVue empStockActu = new EmployeStockVue();

            empStockActu.Carte = cartee.Libelle;
            empStockActu.Nom   = employee.Nom;
            List <EmployeStockVue> listEmpStockActu = empStockService.search(empStockActu);

            //insertion de la distribution
            distribCarteService.insert(carteDist);

            //mise a jour du stock du coursier
            int stock = listEmpStockActu[0].Stock + quantite;

            empStockService.update(new EmployeStock(employe, stock, carte));

            //insertion du nouveau stock du coursier
            employeStockHistoService.insert(new EmployeStockHisto(employe, quantite, carte));

            //Recherche liste carte distribue
            List <DistributionCarteVue> listCarteDistr = distribCarteService.getAll();

            ViewBag.ListCarteDistr = listCarteDistr;
            return(View());
        }
        public IEnumerable <SelectListItem> AgentListForDropDown()
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService EmpService = new EmployeService(UOW);

                    List <Employe>        agents    = EmpService.GetMany(emp => emp.Role.role.Equals("agent") && emp.IsVerified == true).ToList();
                    List <SelectListItem> listItems = new List <SelectListItem>();

                    agents.ForEach(l => {
                        listItems.Add(new SelectListItem {
                            Text = l.Username, Value = l.EmployeId + ""
                        });
                    });

                    return(listItems);
                }
            }
        }
Beispiel #15
0
        public ActionResult Login(Compte compte)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService EmpService = new EmployeService(UOW);

                    Employe emp = EmpService.GetEmployeByUername(compte.Username);

                    if (emp == null)
                    {
                        ModelState.AddModelError("Username", "Nom d'utilisateur inexistant");
                    }
                    else if (emp != null)
                    {
                        if (emp.Password == compte.Password)
                        {
                            if (emp.IsVerified == false)
                            {
                                ModelState.AddModelError("Connect", "Votre compte n'est pas encore validé par un administrateur");
                            }
                            else if (emp.IsVerified == true)
                            {
                                Session["username"] = emp.Username;
                                Session["role"]     = emp.Role.role;
                                return(RedirectToAction("Index", "Home"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("Password", "Mot de passe incorrect");
                        }
                    }

                    return(View());
                }
            }
        }
Beispiel #16
0
        public ActionResult Renseigner(int?page)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LettreService  lettreService  = new LettreService(UOW);
                    LotService     LotService     = new LotService(UOW);
                    EmployeService EmployeService = new EmployeService(UOW);
                    List <Lettre>  lettreList     = lettreService.GetAll().OrderByDescending(f => f.DateExtrait).ToList();
                    ViewData["list"]  = new SelectList(NumLotListForDropDown(LotService), "Value", "Text");
                    ViewBag.AgentList = new SelectList(AgentListForDropDown(EmployeService), "Value", "Text");


                    ViewBag.total = lettreList.Count();

                    int pageSize   = 10;
                    int pageNumber = (page ?? 1);
                    return(View(lettreList.ToPagedList(pageNumber, pageSize)));
                }
            }
        }
        public ActionResult Create([Bind(Include = "IdEmploye,Matricule,NomComplet,DateEmbauche,IdPoste,IdDepartement,Actif,Ville,Email,Telephone")] Employe employe)
        {
            if (ModelState.IsValid)
            {
                var employeService = new EmployeService();
                if (!employeService.Exist(employe.Matricule))
                {
                    var employeRepository = new EmployeRepository();
                    employeRepository.AddEmploye(employe);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Matricule", "Ce matricule existe déjà");
                }
            }

            ViewBag.IdDepartement = new SelectList(db.Departement, "IdDepartement", "NomDepartement", employe.IdDepartement);
            ViewBag.IdPoste       = new SelectList(db.Poste, "IdPoste", "NomPoste", employe.IdPoste);
            return(View(employe));
        }
        public DataTable GenerateDatatableFromJoinedList(List <ClientCompte> list)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    EmployeService     EmpService         = new EmployeService(UOW);

                    List <ClientCompte> newList   = new List <ClientCompte>();
                    DataTable           dataTable = new DataTable();

                    newList = list.Select(j =>
                                          new ClientCompte
                    {
                        Nom    = j.Nom,
                        Compte = j.Compte
                    }).ToList();

                    dataTable.Columns.Add("Nom", typeof(string));
                    dataTable.Columns.Add("Compte", typeof(string));

                    foreach (ClientCompte c in newList)
                    {
                        DataRow row = dataTable.NewRow();
                        row["Nom"]    = c.Nom;
                        row["Compte"] = c.Compte;
                        dataTable.Rows.Add(row);
                    }

                    Debug.WriteLine("---->" + dataTable.Rows.Count);

                    return(dataTable);
                }
            }
        }
        public ActionResult updateLot(int id)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    EmployeService     EmpService         = new EmployeService(UOW);


                    ViewData["list"]  = new SelectList(NumLotListForDropDown(), "Value", "Text");
                    ViewData["agent"] = new SelectList(AgentListForDropDown(), "Value", "Text");

                    //Lot lot = LotService.GetById(id);
                    ClientAffecteViewModel cavm = new ClientAffecteViewModel();
                    cavm = (from a in AffectationService.GetAll()
                            join l in LotService.GetAll() on a.LotId equals l.LotId
                            where l.LotId == id
                            select new ClientAffecteViewModel
                    {
                        Affectation = a,
                        Lot = l
                    }).FirstOrDefault();

                    if (cavm == null)
                    {
                        cavm = new ClientAffecteViewModel();
                        Lot lot = LotService.GetById(id);
                        cavm.Lot = lot;
                    }

                    return(View(cavm));
                }
            }
        }
Beispiel #20
0
        public ActionResult UpdateAccount(int id, Employe e)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService EmpService  = new EmployeService(UOW);
                    RoleService    RoleService = new RoleService(UOW);

                    var Roles = RoleService.GetAll();
                    ViewBag.RoleList = new SelectList(Roles, "RoleId", "role");

                    Employe emp = EmpService.GetById(id);
                    emp.RoleId          = e.RoleId;
                    emp.IsVerified      = e.IsVerified;
                    emp.ConfirmPassword = emp.Password;

                    EmpService.Update(emp);
                    EmpService.Commit();

                    return(View("AccountList", EmpService.GetAll()));
                }
            }
        }
Beispiel #21
0
 public HistoriqueController()
 {
     demandeService = new DemandeService();
     employeService = new EmployeService();
 }
Beispiel #22
0
 protected override async Task OnInitializedAsync()
 {
     employes = (await EmployeService.GetEmployes()).ToList();
 }
Beispiel #23
0
 public AddEmployeForm(ApplicationDbContext context)
 {
     dbContext      = context;
     employeService = new EmployeService(dbContext);
     InitializeComponent();
 }
 public CustomAutorizationAttribute()
 {
     UtilisateurService = new EmployeService(new RoleService());
 }
Beispiel #25
0
        public ActionResult Index()
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    EmployeService     EmpService         = new EmployeService(UOW);
                    RoleService        RoleService        = new RoleService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);

                    List <ClientAffecteViewModel> traiteList = new List <ClientAffecteViewModel>();

                    List <HomeViewModel> result = new List <HomeViewModel>();
                    List <Lot>           lots   = new List <Lot>();


                    string[] lotsLst = { };

                    lots    = LotService.GetAll().ToList();
                    lotsLst = lots.DistinctBy(l => l.NumLot).Select(l => l.NumLot).ToArray();

                    List <Affectation> Affectations = new List <Affectation>();
                    List <Formulaire>  Formulaires  = new List <Formulaire>();
                    string[]           agents       = { };

                    Affectations = AffectationService.GetAll().ToList();
                    Formulaires  = FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe).ToList();

                    foreach (string numlot in lotsLst)
                    {
                        lots = LotService.GetAll().Where(l => l.NumLot.Equals(numlot)).ToList();

                        traiteList = (from f in Formulaires
                                      join a in Affectations on f.AffectationId equals a.AffectationId
                                      join l in lots on a.LotId equals l.LotId
                                      select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).ToList();

                        var agentLinq = (from a in Affectations
                                         join l in lots on a.LotId equals l.LotId
                                         select new ClientAffecteViewModel
                        {
                            Affectation = a
                        });


                        agents = agentLinq.DistinctBy(a => a.Affectation.Employe.Username).Select(a => a.Affectation.Employe.Username).ToArray();

                        string agentsStr = string.Join(", ", agents);

                        float  nbAffTotal = agentLinq.Count();
                        float  nbTraite   = traiteList.Count();
                        string avgLot     = String.Format("{0:0.00}", (nbTraite / nbAffTotal) * 100);


                        HomeViewModel homeViewModel = new HomeViewModel
                        {
                            agents     = agentsStr,
                            nbAffTotal = nbAffTotal + "",
                            nbTraite   = nbTraite + "",
                            numLot     = numlot,
                            avancement = avgLot.Replace(",", ".")
                        };
                        result.Add(homeViewModel);
                    }

                    return(View(result));
                }
            }
        }
        public ActionResult StatLot(int numLot, string typeStat, string dateStat, string agent)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    LotService         LotService         = new LotService(UOW);
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    EmployeService     EmpService         = new EmployeService(UOW);

                    ViewData["list"]      = new SelectList(NumLotListForDropDown(), "Value", "Text");
                    ViewData["sortOrder"] = new SelectList(TypeStatForDropDown(), "Value", "Text");
                    ViewBag.AgentList     = new SelectList(AgentListForDropDown(), "Value", "Text");

                    int nb        = 0;
                    int rdv       = 0;
                    int fn        = 0;
                    int versement = 0;
                    int encours   = 0;

                    string avgRdv     = 0 + "";
                    string avgVers    = 0 + "";
                    string avgFn      = 0 + "";
                    string avgencours = 0 + "";


                    ViewData["years"] = new SelectList(YearListForDropDown(), "Value", "Text");
                    ViewData["month"] = new SelectList(MonthListForDropDown(), "Value", "Text");

                    List <Affectation>            affectations = new List <Affectation>();
                    List <Lot>                    lots         = new List <Lot>();
                    List <ClientAffecteViewModel> rdvCAVm      = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> fnCAVm       = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> versCAVm     = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> encoursCAVm  = new List <ClientAffecteViewModel>();
                    List <ClientAffecteViewModel> tot          = new List <ClientAffecteViewModel>();

                    if (numLot == 0)
                    {
                        tot = (from a in AffectationService.GetAll()
                               join l in LotService.GetAll() on a.LotId equals l.LotId
                               select new ClientAffecteViewModel
                        {
                            Affectation = a,
                            Lot = l,
                        }).ToList();


                        rdvCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                   join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                   join l in LotService.GetAll() on a.LotId equals l.LotId

                                   select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.RDV).ToList();


                        fnCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId

                                  select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.FAUX_NUM).ToList();


                        versCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                    join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                    join l in LotService.GetAll() on a.LotId equals l.LotId

                                    select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.SOLDE_TRANCHE || f.Formulaire.EtatClient == Note.SOLDE).ToList();


                        encoursCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                       join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                       join l in LotService.GetAll() on a.LotId equals l.LotId

                                       select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.REFUS_PAIEMENT || f.Formulaire.EtatClient == Note.RAPPEL || f.Formulaire.EtatClient == Note.RACCROCHE || f.Formulaire.EtatClient == Note.NRP || f.Formulaire.EtatClient == Note.INJOIGNABLE || f.Formulaire.EtatClient == Note.AUTRE || f.Formulaire.EtatClient == Note.A_VERIFIE).ToList();
                    }
                    else
                    {
                        tot = (from a in AffectationService.GetAll()
                               join l in LotService.GetAll() on a.LotId equals l.LotId
                               where l.NumLot == numLot.ToString()
                               select new ClientAffecteViewModel
                        {
                            Affectation = a,
                            Lot = l,
                        }).ToList();


                        rdvCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                   join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                   join l in LotService.GetAll() on a.LotId equals l.LotId
                                   where l.NumLot == numLot + ""

                                   select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.RDV).ToList();


                        fnCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                  join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                  join l in LotService.GetAll() on a.LotId equals l.LotId
                                  where l.NumLot == numLot + ""

                                  select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.FAUX_NUM).ToList();


                        versCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                    join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                    join l in LotService.GetAll() on a.LotId equals l.LotId
                                    where l.NumLot == numLot + ""

                                    select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.SOLDE_TRANCHE || f.Formulaire.EtatClient == Note.SOLDE).ToList();


                        encoursCAVm = (from f in FormulaireService.GetAll().OrderByDescending(o => o.TraiteLe)
                                       join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                       join l in LotService.GetAll() on a.LotId equals l.LotId
                                       where l.NumLot == numLot + ""

                                       select new ClientAffecteViewModel
                        {
                            Formulaire = f,
                            Affectation = a,
                            Lot = l,
                        }).DistinctBy(d => d.Formulaire.AffectationId).Where(f => f.Formulaire.EtatClient == Note.REFUS_PAIEMENT || f.Formulaire.EtatClient == Note.RAPPEL || f.Formulaire.EtatClient == Note.RACCROCHE || f.Formulaire.EtatClient == Note.NRP || f.Formulaire.EtatClient == Note.INJOIGNABLE || f.Formulaire.EtatClient == Note.AUTRE || f.Formulaire.EtatClient == Note.A_VERIFIE).ToList();
                    }

                    if (typeStat == "1")
                    {
                        nb        = tot.Count();
                        rdv       = rdvCAVm.Count();
                        fn        = fnCAVm.Count();
                        versement = versCAVm.Count();
                        encours   = encoursCAVm.Count();

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }
                    else if (typeStat == "2")
                    {
                        rdv       = rdvCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        fn        = fnCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        versement = versCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        encours   = encoursCAVm.Where(f => f.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();

                        nb = rdv + fn + versement + encours;

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }
                    else if (typeStat == "3")
                    {
                        rdv       = rdvCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();
                        fn        = fnCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();
                        versement = versCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();
                        encours   = encoursCAVm.Where(a => a.Affectation.EmployeId + "" == agent).Count();

                        nb = rdv + fn + versement + encours;

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }
                    else if (typeStat == "4")
                    {
                        rdv       = rdvCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        fn        = fnCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        versement = versCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();
                        encours   = encoursCAVm.Where(a => a.Affectation.EmployeId + "" == agent && a.Formulaire.TraiteLe.Date == DateTime.Parse(dateStat).Date).Count();

                        nb = rdv + fn + versement + encours;

                        avgRdv     = String.Format("{0:0.00}", ((float)rdv / (float)nb) * 100);
                        avgFn      = String.Format("{0:0.00}", ((float)fn / (float)nb) * 100);
                        avgVers    = String.Format("{0:0.00}", ((float)versement / (float)nb) * 100);
                        avgencours = String.Format("{0:0.00}", ((float)encours / (float)nb) * 100);
                    }

                    StatLot statLot = new StatLot()
                    {
                        nb         = nb,
                        rdv        = rdv,
                        fn         = fn,
                        versement  = versement,
                        encours    = encours,
                        avgRdv     = avgRdv.Replace(",", "."),
                        avgFn      = avgFn.Replace(",", "."),
                        avgVers    = avgVers.Replace(",", "."),
                        avgencours = avgencours.Replace(",", ".")
                    };

                    return(View("Index", statLot));
                }
            }
        }
Beispiel #27
0
        public async Task GetEmployeList()
        {
            EmployeService employeService = new EmployeService();

            Employes = await employeService.GetEmployeAsync();
        }
Beispiel #28
0
        public ActionResult ExtraireLettreAction(string numLot, string debutDate, string finDate, string agent)
        {
            using (WakilRecouvContext WakilContext = new WakilRecouvContext())
            {
                using (UnitOfWork UOW = new UnitOfWork(WakilContext))
                {
                    FormulaireService  FormulaireService  = new FormulaireService(UOW);
                    AffectationService AffectationService = new AffectationService(UOW);
                    LotService         LotService         = new LotService(UOW);
                    LettreService      lettreService      = new LettreService(UOW);
                    EmployeService     EmployeService     = new EmployeService(UOW);

                    ViewData["list"]  = new SelectList(NumLotListForDropDown(LotService), "Value", "Text");
                    ViewBag.AgentList = new SelectList(AgentListForDropDown(EmployeService), "Value", "Text");

                    string   lettreDir = GetFolderNameForLettre();
                    DateTime startDate = DateTime.Parse(debutDate);
                    DateTime endDate   = DateTime.Parse(finDate);

                    if (!Directory.Exists(lettreDir))
                    {
                        Directory.CreateDirectory(lettreDir);
                    }

                    string lettreDirList = Directory.GetDirectories(lettreDir).Length + 1 + "_" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() + "";

                    string dirLettre = "";

                    if (!Directory.Exists(lettreDir + "/" + lettreDirList))
                    {
                        Directory.CreateDirectory(lettreDir + "/" + lettreDirList);
                        dirLettre = lettreDir + "/" + lettreDirList;
                    }

                    List <LettreContent> lettreJoinedList = new List <LettreContent>();

                    if (numLot == "0")
                    {
                        lettreJoinedList = (from f in FormulaireService.GetAll()
                                            join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                            join l in LotService.GetAll() on a.LotId equals l.LotId
                                            where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId)
                                            select new LettreContent
                        {
                            NumLot = l.NumLot,
                            Adresse = l.Adresse,
                            NomClient = l.NomClient,
                            Agence = l.DescIndustry,
                            Compte = l.Compte
                        }).ToList();

                        if (int.Parse(agent) != 0)
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && a.EmployeId == int.Parse(agent)
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte
                            }).ToList();
                        }
                        else
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId)
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte
                            }).ToList();
                        }
                    }
                    else
                    {
                        if (int.Parse(agent) != 0)
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && (l.NumLot.Equals(numLot)) && a.EmployeId == int.Parse(agent)
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte,
                                IdAgent = a.EmployeId + ""
                            }).ToList();
                        }
                        else
                        {
                            lettreJoinedList = (from f in FormulaireService.GetAll()
                                                join a in AffectationService.GetAll() on f.AffectationId equals a.AffectationId
                                                join l in LotService.GetAll() on a.LotId equals l.LotId
                                                where (f.TraiteLe.Date >= startDate.Date && f.TraiteLe.Date <= endDate.Date) && (f.EtatClient == Note.FAUX_NUM || f.EtatClient == Note.NRP || f.EtatClient == Note.INJOIGNABLE) && lettreIsTrue(FormulaireService, a.AffectationId) && (l.NumLot.Equals(numLot))
                                                select new LettreContent
                            {
                                NumLot = l.NumLot,
                                Adresse = l.Adresse,
                                NomClient = l.NomClient,
                                Agence = l.DescIndustry,
                                Compte = l.Compte,
                                IdAgent = a.EmployeId + ""
                            }).ToList();
                        }
                    }



                    int x = 0;
                    ViewBag.total = lettreJoinedList.Count();
                    foreach (LettreContent lc in lettreJoinedList)
                    {
                        string path = dirLettre + "/" + x + "_" + "lettre" + "_" + lc.Compte + ".docx";

                        if (Directory.Exists(dirLettre))
                        {
                            GenerateWordForLettre(path, lc);
                        }
                        ViewData["currClient"] = x;
                        x++;
                    }

                    string zipPath = zipFolderResult(dirLettre);

                    string adressExcelPath = Server.MapPath("~/Uploads/Lettre/0_Result/") + DateTime.Now.ToString("dd.MM.yyyy") + "_" + Path.GetFileName(dirLettre) + ".xlsx";

                    GenerateExcelForLettre(GenerateDatatableFromJoinedListForLettre(lettreJoinedList), adressExcelPath);
                    Lettre lettre = new Lettre
                    {
                        DateDeb              = startDate.Date,
                        DateFin              = endDate.Date,
                        DateExtrait          = DateTime.Now,
                        LettrePathName       = zipPath,
                        LettreAdressPathName = Path.GetFileName(adressExcelPath)
                    };

                    lettreService.Add(lettre);
                    lettreService.Commit();

                    return(RedirectToAction("Renseigner", new { page = 1 }));
                }
            }
        }
Beispiel #29
0
 public EmployeController()
 {
     employeService = new EmployeService();
 }