public async Task <ActionResult> EditAsync(int id, AbsenceModel absence) { try { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); if (!ModelState.IsValid) { float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; return(View()); } absence.Status = AbsenceStatus.AValider; absence.User = compte.User; await _absenceService.UpdateAsync(HttpContext.Session, absence); return(RedirectToAction("Index")); } catch { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; return(View()); } }
public async Task <ActionResult <CompteModel> > Post(int id, CompteModel model) { try { var lien = link.GetPathByAction("Get", "Comptes", values: new { id, id2 = model.CompteId }); var client = await gestionnaire.GetClient(id); if (client == null) { return(BadRequest("id introuvable")); } var compte = mapper.Map <Compte>(model); compte.Client = client; gestionnaire.Add(compte); if (await gestionnaire.SaveChanges()) { return(Created(lien, mapper.Map <CompteModel>(compte))); } return(BadRequest("error")); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public async Task <ActionResult> DetailsAsync(int id) { CompteModel compte = await _compteService.GetAsync(HttpContext.Session, id); ViewData.Model = compte; return(View()); }
// GET: User/Edit/5 public async Task <IActionResult> Edit(long id) { ProjetModel projet = await _projetService.GetAsync(HttpContext.Session, id); var lstUserByProjet = (await _projetService.GetListUserByProjectAsync(HttpContext.Session, projet.Id.GetValueOrDefault(0))).Select(s => new { Id = s.Id, Nom = s.Nom, Prenom = s.Prenom, Selected = true }).ToList(); CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <UserModel> lstUser = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); var listUserTolal = lstUser.Where(w => lstUserByProjet == null || lstUserByProjet.Where(x => x.Id == w.Id).Count() == 0) .Select(s => new { Id = s.Id, Nom = s.Nom, Prenom = s.Prenom, Selected = false }).Concat(lstUserByProjet).ToList(); //for(int i = 0; i < listUserTolal.Count();i++) { } ViewBag.lstUser = listUserTolal ?? new[] { new { Id = (long?)0, Nom = "", Prenom = "", Selected = false } }.ToList(); ViewData.Model = projet; return(View()); }
// GET: User/Edit/5 public async Task <IActionResult> Edit(long id) { EvaluationModel evals = await _evaluationService.GetAsync(HttpContext.Session, id); CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); SujetModel sujets = await _sujetService.GetAsync(HttpContext.Session, id); List <UserModel> lstUser = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); var lstUserByEval = (await _evaluationService.GetListUserByEvalAsync(HttpContext.Session, evals.Id.GetValueOrDefault(0))).Select(s => new { Id = s.Id, Nom = s.Nom, Prenom = s.Prenom, Selected = true }).ToList(); var listUserTolal = lstUser.Where(w => lstUserByEval == null || lstUserByEval.Where(x => x.Id == w.Id).Count() == 0) .Select(s => new { Id = s.Id, Nom = s.Nom, Prenom = s.Prenom, Selected = false }).Concat(lstUserByEval).ToList(); //for(int i = 0; i < listUserTolal.Count();i++) { } ViewBag.lstUser = listUserTolal ?? new[] { new { Id = (long?)0, Nom = "", Prenom = "", Selected = false } }.ToList(); List <SujetModel> lstsujet = await _sujetService.GetListAsync(HttpContext.Session); var lstSujetsByEval = (await _evaluationService.GetListSujetByEvalAsync(HttpContext.Session, evals.Id.GetValueOrDefault(0))).Select(s => new { Id = s.Id, Titre = s.Titre, Selected = true }).ToList(); var listTotal = lstsujet.Where(w => lstSujetsByEval == null || lstSujetsByEval.Where(x => x.Id == w.Id).Count() == 0) .Select(s => new { Id = s.Id, Titre = s.Titre, Selected = false }).Concat(lstSujetsByEval).ToList(); //for(int i = 0; i < listUserTolal.Count();i++) { } ViewBag.lstsujet = listTotal ?? new[] { new { Id = (long?)0, Titre = "", Selected = false } }.ToList(); ViewData.Model = evals; return(View()); }
public IActionResult AddCompte([FromBody] CompteModel model) { try { Client client = _context.Clients.Where(c => c.UtilisateurId.Equals(model.ClientId)).FirstOrDefault(); Compte compteATrouver = _context.Comptes.Where(c => ( c.ClientId.Equals(client.UtilisateurId) && c.NomCompte.Equals(model.NomCompte) )).FirstOrDefault(); if (compteATrouver == null) { Compte newCompte = new Compte() { ClientId = client.UtilisateurId, DateCreation = System.DateTime.Now, NomCompte = model.NomCompte }; Panier newPanier = new Panier() { Compte = newCompte }; _context.Comptes.Add(newCompte); _context.Paniers.Add(newPanier); _context.SaveChanges(); return(Ok()); } } catch (Exception) { } return(BadRequest()); }
//GET: /<controller> public async Task <IActionResult> List() { var WeekOfYear = cultureInfo.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday); CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <RapportModel> rapports = await _rapportService.GetListAllrapportByUser(HttpContext.Session, WeekOfYear, compte.User.Id.GetValueOrDefault(0)); List <CustomModel> historiqueRapport = new List <CustomModel>(); if (rapports.Count() > 0) { var ListOfRapports = rapports.GroupBy(x => new { x.Semaine, x.Annee, x.Mois }) .Select(g => g) .ToList(); foreach (var item in ListOfRapports) { CustomModel RapportGBS = new CustomModel(); RapportGBS.Semaine = (int)item.Key.Semaine; RapportGBS.Mois = (int)item.Key.Mois; RapportGBS.Annee = (int)item.Key.Annee; RapportGBS.Rapports = item.ToArray(); historiqueRapport.Add(RapportGBS); } } ViewBag.historiqueRapport = historiqueRapport; return(View()); }
// GET: Mission/Create public async Task <ActionResult> CreateAsync() { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <ProjetModel> result = await _projetService.GetListProjectByManager(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.listprojet = result ?? new List <ProjetModel>(); return(View()); }
// GET: /<controller>/ public async Task <IActionResult> view(int semaine, int annee, int mois) { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <RapportModel> rapports = await _rapportService.GetListrapportByUserAndWeek(HttpContext.Session, semaine, mois, annee, compte.User.Id.GetValueOrDefault(0)); ViewBag.rapports = rapports ?? new List <RapportModel> (); return(View()); }
public async Task <ActionResult> CreateAsync() { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; return(View()); }
public async Task <ActionResult> CreateAsync(CompteModel compte, int idUser, List <long> roles) { try { if (!string.IsNullOrEmpty(compte.Username)) { bool exists = await _compteService.ExistsUsername(HttpContext.Session, compte.Username); if (exists) { ModelState.AddModelError(nameof(compte.Username), "Username already exists, please choose another"); } } if (!ModelState.IsValid) { List <UserModel> users = await _userService.GetListAsync(HttpContext.Session); ViewBag.UserList = users; List <RoleModel> rolesList = await _roleService.GetListAsync(HttpContext.Session); ViewBag.RoleList = rolesList; return(View()); } if (roles != null) { List <RoleModel> rolesList = new List <RoleModel>(); foreach (long idRole in roles) { rolesList.Add(new RoleModel { Id = idRole }); } compte.Roles = rolesList; } compte.User = new UserModel { Id = idUser }; await _compteService.AddAsync(HttpContext.Session, compte); UserModel user = await _userService.GetAsync(HttpContext.Session, idUser); await _mailService.SendMailAsync(HttpContext.Session, user.Email, "[Atlas] Compte créé", "NewComptePassword.html", new Dictionary <string, string> { { "#_USER_FULLNAME_#", user.FullName }, { "#_USERNAME_#", compte.Username }, { "#_PASSWORD_#", compte.Password } }); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> EditAsync(int id) { CompteModel compte = await _compteService.GetAsync(HttpContext.Session, id); ViewData.Model = compte; List <RoleModel> roles = await _roleService.GetListAsync(HttpContext.Session); ViewBag.RoleList = roles; return(View()); }
public async Task <ActionResult> CreateAsync() { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <UserModel> users = await _userService.GetListAsync(HttpContext.Session); users.Remove(compte.User); ViewBag.users = users; return(View()); }
// GET: /<controller>/ public async Task <IActionResult> Index() { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <UserModel> result = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.lstUser = result ?? new List <UserModel>(); //GET LIST OF USER By manager return(View()); }
// GET: Mission/Edit/5 public async Task <ActionResult> EditAsync(int id) { MissionModel mission = await _missionService.GetAsync(HttpContext.Session, id); ViewData.Model = mission; CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <ProjetModel> result = await _projetService.GetListProjectByManager(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.listprojet = result ?? new List <ProjetModel>(); return(View()); }
public async Task <ActionResult> DeleteAsync(int id, CompteModel compte) { try { await _compteService.DeleteAsync(HttpContext.Session, id); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> EditAsync(int id) { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; AbsenceModel absence = await _absenceService.GetAsync(HttpContext.Session, id); ViewData.Model = absence; return(View()); }
public async Task <ActionResult> Edit(int id) { UserModel user = await _userService.GetAsync(HttpContext.Session, id); ViewData.Model = user; CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <UserModel> users = await _userService.GetListAsync(HttpContext.Session); users.Remove(compte.User); ViewBag.users = users; return(View()); }
// GET: Frais/Create public async Task <ActionResult> CreateAsync() { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <MissionModel> result = await _missionService.GetListAsync(HttpContext.Session); ViewBag.listmission = result ?? new List <MissionModel>(); List <UserModel> listusers = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); listusers = listusers ?? new List <UserModel>(); listusers.Add(compte.User); ViewBag.userlist = listusers; return(View()); }
// GET: /<controller>/ public async Task <IActionResult> ListeAsync() { //GET LIST OF USER By manager CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <UserModel> result = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); List <EvaluationModel> eval = await _evaluationService.GetListEvalByUser(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.lstEval = eval ?? new List <EvaluationModel>(); return(View()); }
private bool CheckIfHasPermission(AuthorizationFilterContext context) { CompteModel compte = _compteService.GetConnectedCompte(context.HttpContext.Session); foreach (RankEnum rank in _authorizedRanks) { if (_compteService.HasRole(context.HttpContext.Session, rank)) { return(true); } } return(false); }
public IActionResult ModifierCompte(int CompteId, [FromBody] CompteModel model) { try { Compte compte = _context.Comptes.Where(c => c.CompteId.Equals(CompteId)).FirstOrDefault(); compte.NomCompte = model.NomCompte; return(Ok()); } catch (Exception) { } return(BadRequest()); }
public async Task <IActionResult> IndexAsync([Bind("Username", "Password")] CompteModel compte) { try { CompteModel loggedIn = await _compteService.LoginAsync(HttpContext.Session, compte.Username, compte.Password); //RestApiResponse<List<FormationModel>> s = await _restApiClient.GetAsync<List<FormationModel>>(HttpContext.Session, "formation"); return(RedirectToAction("Index", "Home")); } catch (Exception) { ViewBag.Error = "Username or password are incorrect, please login"; //return null; return(View()); } }
public async Task <ActionResult> CreateAsync(FraisModel model, long?missionId, long?userId) { try { if (!ModelState.IsValid) { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <MissionModel> result = await _missionService.GetListAsync(HttpContext.Session); ViewBag.listmission = result ?? new List <MissionModel>(); List <UserModel> listusers = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); listusers = listusers ?? new List <UserModel>(); listusers.Add(compte.User); ViewBag.userlist = listusers; return(View()); } string uniqueFileName = UploadedFile(model); model.Justificatif = uniqueFileName; model.Mission = new MissionModel { Id = missionId }; UserModel userSelected = await _userService.GetAsync(HttpContext.Session, userId); model.User = userSelected; await _fraisService.AddAsync(HttpContext.Session, model); return(RedirectToAction("Index")); } catch { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <MissionModel> result = await _missionService.GetListAsync(HttpContext.Session); ViewBag.listmission = result ?? new List <MissionModel>(); List <UserModel> listusers = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); listusers = listusers ?? new List <UserModel>(); listusers.Add(compte.User); ViewBag.userlist = listusers; return(View()); } }
public async Task <IActionResult> List() { //GET LIST OF USER By manager CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <ProjetModel> result = await _projetService.GetListProjectByManager(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); foreach (ProjetModel element in result) { List <RubriqueModel> rubriques = await _rubriqueService.GetListRubriqueByProjet(HttpContext.Session, element.Id); foreach (RubriqueModel item in rubriques) { element.EstimationTotal = element.EstimationTotal + (float)item.Estimation; } } ViewBag.lstmanager = result ?? new List <ProjetModel>(); return(View()); }
public async Task <IActionResult> AddProject([Bind("Titre", "DateCreation", "DateCloture")] ProjetModel projet, List <long> membres) { try { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); projet.createdBy = compte.User; ProjetModel prj = await _projetService.AddAsync(HttpContext.Session, projet); foreach (long item in membres) { await _projetService.AffecterUserToProjetAsync(HttpContext.Session, prj.Id, item); } return(RedirectToAction("List", "Projet")); } catch (Exception e) { //return null; return(View()); } }
public async Task <ActionResult> IndexAsync() { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <AbsenceModel> myAbsences = await _absenceService.GetListAbsenceForUser(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.myAbsences = myAbsences; List <AbsenceModel> toValidateAbsencesManager = await _absenceService.GetListAbsenceByStatusForManager(HttpContext.Session, AbsenceStatus.AValider, compte.User.Id.GetValueOrDefault(0)); ViewBag.toValidateAbsencesManager = toValidateAbsencesManager; List <AbsenceModel> toValidateAbsencesHR = await _absenceService.GetListAbsenceByStatus(HttpContext.Session, AbsenceStatus.AValider); toValidateAbsencesHR = toValidateAbsencesHR ?? new List <AbsenceModel>(); toValidateAbsencesHR = toValidateAbsencesHR.Where(w => w.Type != AbsenceType.Conge).ToList(); ViewBag.toValidateAbsencesHR = toValidateAbsencesHR; float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; return(View()); }
public async Task <IActionResult> AddEval([Bind("Titre")] EvaluationModel evaluation, List <long> membres, List <long> list) { try { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); evaluation.CreatedBy = compte.User; evaluation.Status = "Created"; EvaluationModel evaluations = await _evaluationService.AddAsync(HttpContext.Session, evaluation); foreach (long item in list) { List <QuestionModel> qst = await _questionService.GetQuestionBySujet(HttpContext.Session, item); foreach (QuestionModel element in qst) { ResponseModel rps = new ResponseModel(); rps.Evaluation = evaluations; rps.Question = element; await _reponseService.AddAsync(HttpContext.Session, rps); } } foreach (long item in membres) { await _evaluationService.AffecterUserToEvaluationAsync(HttpContext.Session, evaluations.Id, item); } return(RedirectToAction("Liste", "Evaluation")); } catch (Exception e) { //return null; return(View()); } }
// GET: /<controller>/ public async Task <IActionResult> view(long id) { //GET LIST OF USER By manager CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); List <UserModel> result = await _userService.GetListUserByManagerAsync(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); List <EvaluationModel> eval = await _evaluationService.GetListEvalByUser(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); EvaluationModel evaluation = await _evaluationService.GetAsync(HttpContext.Session, id); List <ResponseModel> rep = await _reponseService.GetReponseByEvalAsync(HttpContext.Session, id); List <ReponsePass> Lstrepo = new List <ReponsePass>(); foreach (ResponseModel item in rep) { ReponsePass rp = new ReponsePass(); rp.sujets = item.Question.Sujet; rp.questions = item.Question; rp.evals = item.Evaluation; if (item.Question.Type != "text") { List <ChoixModel> CM = await _choixservice.getChoixByQuestion(HttpContext.Session, id); rp.choix = CM; } Lstrepo.Add(rp); } ViewBag.lstEval = Lstrepo ?? new List <ReponsePass>(); return(View()); }
public async Task <ActionResult> CreateAsync(AbsenceModel absence) { try { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); if (!ModelState.IsValid) { float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; return(View()); } absence.Status = AbsenceStatus.AValider; absence.User = compte.User; await _absenceService.AddAsync(HttpContext.Session, absence); if (absence.Type == AbsenceType.Conge && compte.User.Chef != null) { await _mailService.SendMailAsync(HttpContext.Session, compte.User.Chef.Email, "[Atlas] Demande de congé", "DemandeConge.html", new Dictionary <string, string> { { "#_USER_FULLNAME_#", compte.User.FullName }, { "#_MANAGER_FULLNAME_#", compte.User.Chef.FullName } }); } return(RedirectToAction("Index")); } catch { CompteModel compte = _compteService.GetConnectedCompte(HttpContext.Session); float soldeCongee = await _absenceService.GetSoldeCongee(HttpContext.Session, compte.User.Id.GetValueOrDefault(0)); ViewBag.soldeCongee = soldeCongee; return(View()); } }