public ActionResult CreateEmploye(EmployeesModel empModel) { EmployesRepositery empRp = new EmployesRepositery(); Employees emp = new Employees(); if (!ModelState.IsValidField("FirstName") || !ModelState.IsValidField("LastName") || !ModelState.IsValidField("Email") || !ModelState.IsValidField("Telephone")) { empModel.AspNetUsersList = empRp.getAllUsers().ToList(); empModel.polesList = empRp.getAllPoles().ToList(); return(View("EmployesFormulaire", empModel)); } emp.Employee_ID = Guid.NewGuid(); String userUmail = Convert.ToString(Request.Form["userList"]); emp.User_ID = empRp.getUserByMail(userUmail); if (empRp.getAllPoles().ToList().Count() == 0) { emp.Pole_ID = null; } else { emp.Pole_ID = new Guid(Convert.ToString(Request.Form["poleList"])); } emp.FirstName = Convert.ToString(Request.Form["FirstName"]); emp.LastName = Convert.ToString(Request.Form["LastName"]); emp.Email = Convert.ToString(Request.Form["Email"]); emp.Telephone = Convert.ToString(Request.Form["Telephone"]); empRp.AddEmployes(emp); return(RedirectToAction("AllEmployees")); }
public ActionResult createExpanseReportsDateDay(String userName) { ViewData["userName"] = userName; ViewData["month"] = Convert.ToInt32(Request.Form["Month"]); ViewData["year"] = Convert.ToInt32(Request.Form["Year"]); int mois = Convert.ToInt32(Request.Form["Month"]); var userId = User.Identity.GetUserId(); ExpanseRepportRepositery expRepRepo = new ExpanseRepportRepositery(); EmployesRepositery empRepository = new EmployesRepositery(); ExpanseReports exp = new ExpanseReports(); var idEmployer = empRepository.GetByIdUser(userId).Employee_ID; var actor_id = idEmployer; exp.ExpanseReport_ID = Guid.NewGuid(); exp.CreationDate = DateTime.Now; exp.Year = Convert.ToInt32(Request.Form["Year"]); exp.Month = mois; exp.StatusCode = Convert.ToInt32(00); exp.ManagerValidationDate = Convert.ToDateTime(Request.Form["CreationDate"]); exp.ManagerComment = Convert.ToString(" no comment"); exp.AccountingValidatationDate = Convert.ToDateTime(Request.Form["CreationDate"]); exp.AccountingComment = Convert.ToString(" no comment"); exp.Total_HT = Convert.ToDouble(0); exp.Total_TTC = Convert.ToDouble(0); exp.Total_TVA = Convert.ToDouble(0); exp.Employee_ID = idEmployer; exp.Author_ID = actor_id; expRepRepo.AddExpansesReports(exp); return(RedirectToAction("AllExpanses", "Expanses", new { idExpanseReport = exp.ExpanseReport_ID })); }
public ActionResult Searche(int?pageIndex, String query) { var countElementPage = 10; EmployesRepositery empRp = new EmployesRepositery(); AspNetUsers user = new AspNetUsers(); PolesModel pole = new PolesModel(); var employers = empRp.getSerachingemployees(query); List <EmployeesModel> employersModel = new List <EmployeesModel>(); foreach (var emp in employers) { var polId = emp.Pole_ID != null ? emp.Pole_ID : null; EmployeesModel empModel = new EmployeesModel(); empModel.Email = emp.Email; empModel.Employee_ID = emp.Employee_ID; empModel.FirstName = emp.FirstName; empModel.LastName = emp.LastName; empModel.Telephone = emp.Telephone; empModel.User_ID = emp.User_ID; empModel.Pole_ID = emp.Pole_ID; empModel.AspNetUsers = empRp.getUserById(emp.User_ID); empModel.Poles.Name = empRp.getPoleById(emp.Pole_ID).Name; employersModel.Add(empModel); } IQueryable <EmployeesModel> listEmp = employersModel.AsQueryable(); PaginatedList <EmployeesModel> lst = new PaginatedList <EmployeesModel>(listEmp, pageIndex, countElementPage); return(View("Allmployes", lst)); }
public ActionResult createUserRole() { EmployeesModel empModel = new EmployeesModel(); EmployesRepositery empRp = new EmployesRepositery(); empModel.AspNetUsersList = empRp.getAllUsers().ToList(); empModel.polesList = empRp.getAllPoles().ToList(); return(View("EmployesFormulaire", empModel)); }
public ActionResult Index() { EmployeesModel empModel = new EmployeesModel(); EmployesRepositery empRp = new EmployesRepositery(); empModel.AspNetUsersList = empRp.getAllUsers().ToList(); empModel.polesList = empRp.getAllPoles().ToList(); if (empRp.getAllUsers().ToList().Count() == 0) { ViewData["erreur"] = "Utilisateurs et des Poles "; return(View("ErrorEmptyElement")); } return(View("EmployesFormulaire", empModel)); }
public ActionResult AllExpansesReports(int?pageIndex) { var userId = User.Identity.GetUserId(); EmployesRepositery empRepository = new EmployesRepositery(); if (empRepository.GetByIdUser(userId) == null) { ViewData["erreurMessage"] = "Vouns ĂȘtes pas encore Employer"; return(View("ErrorEmptyList")); } var idEmployer = empRepository.GetByIdUser(userId).Employee_ID; ExpanseRepportRepositery expRepRepo = new ExpanseRepportRepositery(); var countElementPage = 10; var expansesReports = expRepRepo.allExpanseReports(idEmployer); List <ExpanseReportsModel> expanseReportModelList = new List <ExpanseReportsModel>(); if (expansesReports.Count() == 0) { ViewData["erreurMessage"] = "Vouns n'avez aucune note de frais"; ViewData["element"] = "ExpanseReports"; ViewData["create"] = "false"; return(View("ErrorEmptyList")); } foreach (var exp in expansesReports) { ExpanseReportsModel expReportModel = new ExpanseReportsModel(); EmployeesModel employer = new EmployeesModel(); expReportModel.ExpanseReport_ID = exp.ExpanseReport_ID; employer.FirstName = expRepRepo.GetByIdEmployes(exp.Employee_ID).FirstName; expReportModel.Employees = employer; expReportModel.CreationDate = exp.CreationDate; expReportModel.Year = exp.Year; expReportModel.Month = exp.Month; expReportModel.StatusCode = exp.StatusCode; expReportModel.ManagerValidationDate = exp.ManagerValidationDate; expReportModel.ManagerComment = exp.ManagerComment; expReportModel.AccountingValidatationDate = exp.AccountingValidatationDate; expReportModel.AccountingComment = exp.AccountingComment; expReportModel.Total_HT = exp.Total_HT; expReportModel.Total_TTC = exp.Total_TTC; expReportModel.Total_TVA = exp.Total_TVA; expanseReportModelList.Add(expReportModel); } IQueryable <ExpanseReportsModel> listExpanseReports = expanseReportModelList.AsQueryable(); PaginatedList <ExpanseReportsModel> lst = new PaginatedList <ExpanseReportsModel>(listExpanseReports, pageIndex, countElementPage); return(View("MyExpanseReports", lst)); }
public ActionResult AllEmployees(int?pageIndex) { var countElementPage = 10; EmployesRepositery empRp = new EmployesRepositery(); AspNetUsers user = new AspNetUsers(); PolesRepository poleRepo = new PolesRepository(); var employers = empRp.allEmployees(); if (employers.Count() == 0) { ViewData["erreurMessage"] = "Aucun employer !"; ViewData["create"] = "false"; return(View("ErrorEmptyList")); } List <EmployeesModel> employersModel = new List <EmployeesModel>(); foreach (var emp in employers) { EmployeesModel empModel = new EmployeesModel(); empModel.Email = emp.Email; empModel.Employee_ID = emp.Employee_ID; empModel.FirstName = emp.FirstName; empModel.LastName = emp.LastName; empModel.Telephone = emp.Telephone; empModel.User_ID = emp.User_ID; empModel.AspNetUsers = empRp.getUserById(emp.User_ID); if (emp.Poles == null) { PolesModel pole = new PolesModel(); pole.Name = "inconnu"; empModel.Poles = pole; } else { PolesModel pole = new PolesModel(); pole.Pole_ID = emp.Poles.Pole_ID; pole.Name = emp.Poles.Name; empModel.Poles = pole; } employersModel.Add(empModel); } IQueryable <EmployeesModel> listEmp = employersModel.AsQueryable(); PaginatedList <EmployeesModel> lst = new PaginatedList <EmployeesModel>(listEmp, pageIndex, countElementPage); return(View("AllEmployes", lst)); }
// GET: Expanses public PartialViewResult Index(String userName) { var userId = User.Identity.GetUserId(); EmployesRepositery empRepository = new EmployesRepositery(); ViewData["employer"] = "false"; if (empRepository.GetByIdUser(userId) == null) { ViewData["employer"] = "true"; } ViewData["userName"] = userName; ExpanseReportsModel model = new ExpanseReportsModel(); model.Year = DateTime.Now.Year; return(PartialView("_MonthYear", model)); }
public ActionResult RolesUsers() { RolesRepositery rolRep = new RolesRepositery(); EmployesRepositery empRp = new EmployesRepositery(); var listRole = rolRep.allRoles(); if (listRole.Count() == 0) { ViewData["erreur"] = "Roles"; return(View("ErrorEmptyElement")); } foreach (var rl in listRole) { rl.AspNetUsersList = empRp.getAllUsers().ToList(); } return(View("AddUserRole", listRole.ToList())); }
public ActionResult Delete(Guid id) { PolesRepository poleRep = new PolesRepository(); ProjetRepositery prjtRepo = new ProjetRepositery(); ExpanseRepositery expRep = new ExpanseRepositery(); EmployesRepositery empRepo = new EmployesRepositery(); ExpanseRepportRepositery expRepRep = new ExpanseRepportRepositery(); List <Projects> projets = prjtRepo.GetByIdPole(id).ToList(); foreach (var pro in projets) { List <Expanses> expList = expRep.GetByProject(pro.Project_ID).ToList(); foreach (var expanse in expList) { expRep.Delete(expanse); } expRep.Save(); prjtRepo.Delete(pro); } prjtRepo.Save(); foreach (var empl in empRepo.getByIdPole(id)) { List <ExpanseReports> expanseReports = expRepRep.GetByEmployesId(empl.Employee_ID).ToList(); foreach (var expRepo in expanseReports) { expRepRep.Delete(expRepo); } expRepRep.Save(); empRepo.Delete(empl); } empRepo.Save(); Poles pole = poleRep.GetById(id); poleRep.Delete(pole); poleRep.Save(); return(RedirectToAction("AllPoles")); }
public ActionResult Searche(String query, int?pageIndex) { EmployesRepositery empRepository = new EmployesRepositery(); var userId = User.Identity.GetUserId(); var idEmployer = empRepository.GetByIdUser(userId).Employee_ID; var countElementPage = 10; ExpanseRepportRepositery expRep = new ExpanseRepportRepositery(); var expanse = expRep.getSerachingExpanseReports(query, idEmployer); List <ExpanseReportsModel> expanseReportModelList = new List <ExpanseReportsModel>(); foreach (var exp in expanse) { ExpanseReportsModel expReportModel = new ExpanseReportsModel(); EmployeesModel employer = new EmployeesModel(); expReportModel.ExpanseReport_ID = exp.ExpanseReport_ID; employer.FirstName = expRep.GetByIdEmployes(exp.Employee_ID).FirstName; expReportModel.Employees = employer; expReportModel.CreationDate = exp.CreationDate; expReportModel.Year = exp.Year; expReportModel.Month = exp.Month; expReportModel.StatusCode = exp.StatusCode; expReportModel.ManagerValidationDate = exp.ManagerValidationDate; expReportModel.ManagerComment = exp.ManagerComment; expReportModel.AccountingValidatationDate = exp.AccountingValidatationDate; expReportModel.AccountingComment = exp.AccountingComment; expReportModel.Total_HT = exp.Total_HT; expReportModel.Total_TTC = exp.Total_TTC; expReportModel.Total_TVA = exp.Total_TVA; expanseReportModelList.Add(expReportModel); } IQueryable <ExpanseReportsModel> listCust = expanseReportModelList.AsQueryable(); PaginatedList <ExpanseReportsModel> lst = new PaginatedList <ExpanseReportsModel>(listCust, pageIndex, countElementPage); return(View("MyExpanseReports", lst)); }