public ActionResult Modifier(String nuComm) { if (Session["id"] != null) { Commande comm = null; ModifCommande modComm = null; IEnumerable <String> listClients = null; IEnumerable <String> listVendeurs = null; try { comm = CommandeDao.GetCommande(nuComm); listClients = ClientDao.GetNuClients(); listVendeurs = VendeurDao.GetNuVendeurs(); modComm = new ModifCommande(comm, listClients, listVendeurs); return(View(modComm)); } catch (MonException e) { return(HttpNotFound()); } } else { return(View("~/Views/Home/Connexion.cshtml")); } }
public void initAdminClient() { ClientDao dao = new ClientDao(); ClientEntity temp = dao.getClientByUsername("admin"); if (temp != null) { dao.DeleteClient("admin"); } ClientEntity client = new ClientEntity(); RoleDao roleDao = new RoleDao(); DepartmentDao departmentDao = new DepartmentDao(); client.Username = "******"; client.Password = "******"; client.RealName = "yangtf"; client.Role = roleDao.getByName("superadmin"); client.Department = departmentDao.getByName("6"); client.encryptPassword(); IList <CatalogEntity> catalogs = new CatalogDao().getAll(); client.Catalogs = catalogs; dao.save(client); }
public ActionResult Ajout() { if (Session["id"] != null) { ModifCommande modComm = null; IEnumerable <String> listClients = null; IEnumerable <String> listVendeurs = null; String max = ""; try { listClients = ClientDao.GetNuClients(); listVendeurs = VendeurDao.GetNuVendeurs(); max = CommandeDao.GetMaxNuComm(); modComm = new ModifCommande(max, listClients, listVendeurs); return(View(modComm)); } catch (MonException e) { return(HttpNotFound()); } } else { return(View("~/Views/Home/Connexion.cshtml")); } }
public static int SaveClient(int clientId, string name, string icn, string pnc, string address) { if (clientId >= 0) //existing user { var c = ClientDao.Find(clientId); c.Name = name; c.ICN = icn; c.PNC = pnc; c.Address = address; ClientDao.Update(c); return(c.Id); } else if (clientId == -1) //new user { var c = new Client(); c.Name = name; c.ICN = icn; c.PNC = pnc; c.Address = address; c = ClientDao.InsertClient(c); return(c.Id); } return(-1); }
public void TestResetPassword() { ClientDao dao = new ClientDao(); string password = dao.resetPassword("admin"); Console.WriteLine(password); }
public void GenerateCodeTest() { using (var db = new DBDataContext()) { var appClient = db.Client.Where(a => a.Deleted == 0).FirstOrDefault(); var userAccount = db.Account.Where(e => e.Deleted == 0).FirstOrDefault(); if (appClient != null && userAccount != null) { var client = new ClientDao().GetClient(appClient.ID); var code = Core.Instance.AuthManager.GenerateCode(client, userAccount); Assert.AreNotEqual(null, code); var token = Core.Instance.AuthManager.GetAccessToken(new AuthorizeCode { AccountId = userAccount.AccountId, ClientId = client.ClientId, CreateTime = DateTime.Now }); Assert.AreNotEqual(null, token); var values = token.Token.FromHexString().AESDecrypt().Split('|'); Assert.AreEqual(values[0], client.ClientId); } } }
public ActionResult Connexion(ConnexionViewModel vm) { using (ISession session = ClientSession.GetClientSession().OpenSession()) { if (vm.EmailOuMatricule == null || vm.MotDePasse == null) { vm.Erreur = "Veuillez entrer tous les informations demandées"; return(View(vm)); } ClientDao clientDao = new ClientDao(); EmployeDao employeDao = new EmployeDao(); Client client = clientDao.GetClientParCourrielEtMotDePasse(vm.EmailOuMatricule, vm.MotDePasse); Employe employee = employeDao.GetEmployeParMatriculeEtMotDePasse(vm.EmailOuMatricule, vm.MotDePasse); if (client != null) { System.Web.HttpContext.Current.Session["UtilisateurConnecté"] = client; return(RedirectToAction("Index")); } else if (employee != null) { System.Web.HttpContext.Current.Session["UtilisateurConnecté"] = employee; return(RedirectToAction("Index")); } else { vm.Erreur = "Courriel/Matricule ou mot de passe invalide. Veuillez réessayer"; } return(View(vm)); } }
public void CreerClient(string nom, string prenom, string mail) { Client clt = new Client { Id = ClientDao.Clients.Count + 1, Nom = nom, Prenom = prenom, Mail = mail, Commandes = new Collection <Commande>() }; ClientDao.Ajoutclient(clt); }
public void TestBasicCreation() { var c = Builder<Client>.CreateNew().Build(); var clientDao = new ClientDao(); clientDao.Add(c); }
public void CreerClient(string n, string p, string m) { Client clt = new Client { Id = ClientDao.Clients.Count + 1, Nom = n, Prenom = p, Mail = m }; ClientDao.AjouterClient(clt); }
public override void SetUp() { this.session = this.Stub <ISession>(); this.sessionFactory = this.Stub <ISessionFactoryEx>(); this.query = this.Stub <IQuery>(); this.target = new ClientDao(); this.target.SessionFactory = this.sessionFactory; }
// ------------------------------------ fonctionnalité permettant l'ajout d'un client--------------------------------------------------------- public void CreerClient(string Nom, string Prenom, string Mail) { Client clt = new Client { Id = ClientDao.Clients.Count + 1, Nom = Nom, Prenom = Prenom, Mail = Mail, Commandes = new List <Commande>() }; ClientDao.AjouterClient(clt); }
public void Atualizar(int id, ClientModelView clientModelView) { var clientDao = new ClientDao(); var client = clientDao.ObeterPorId(id); var clientAt = AtualizarClient(clientModelView, client); clientAt.IdClient = id; clientDao.Atualizar(clientAt); }
public void Inserir(ClientModelView clientModelView) { var client = new Client(); client = PreparaClient(clientModelView, client); var clientDao = new ClientDao(); clientDao.Inserir(client); }
public static bool Delete(long id) { try { return(ClientDao.getDeleteClient(id)); } catch (Exception ex) { throw new Exception("Impossible de supprimer cette enregistrement", ex); } }
public static Client One(long id) { try { return(ClientDao.getOneClient(id)); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public static Client Default() { try { return(ClientDao.getDefaultClient()); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public Client Insert() { try { return(ClientDao.getAjoutClient(client)); } catch (Exception ex) { throw new Exception("Impossible d'inserer cette enregistrement", ex); } }
public bool Update() { try { return(ClientDao.getUpdateClient(client)); } catch (Exception ex) { throw new Exception("Impossible de modifier cette enregistrement", ex); } }
public static List <Client> Liste(String query) { try { return(ClientDao.getListClient(query)); } catch (Exception ex) { throw new Exception("Impossible de retourner la liste des élements", ex); } }
public WorkTaskWithTimesDto[] SelectByYmd(YmdString ymd, bool containsCompleted) { var list = new List <WorkTaskWithTimesDto>(); RepositoryAction.Query(c => { var workTaskDao = new WorkTaskDao(c, null); var workingTimeDao = new WorkingTimeDao(c, null); var processes = new WorkProcessDao(c, null).SelectAll(); var products = new ProductDao(c, null).SelectAll(); var clients = new ClientDao(c, null).SelectAll(); var completedDao = new WorkTaskCompletedDao(c, null); var tasks = workTaskDao.SelectPlaned(ymd, containsCompleted); var times = workingTimeDao.SelectByTaskIds(tasks.Select(t => t.Id).Distinct().ToArray()); var completed = completedDao.SelectCompleted(tasks.Select(t => t.Id).Distinct().ToArray()); foreach (var task in tasks) { var dto = new WorkTaskWithTimesDto { TaskId = new Identity <Domain.Domain.Tasks.WorkTask>(task.Id), ClientName = clients.FirstOrDefault(c => c.Id == task.ClientId)?.Name ?? "", ProcessName = processes.FirstOrDefault(p => p.Id == task.ProcessId)?.Title ?? "", ProductName = products.FirstOrDefault(p => p.Id == task.ProductId)?.Name ?? "", TaskCategory = task.TaskCategory, Title = task.Title, IsCompleted = completed.Any(c => c == task.Id), IsScheduled = task.TaskSource == Domain.Domain.Tasks.TaskSource.Schedule, }; dto.WorkingTimes = times.Where(t => t.TaskId == task.Id) .Select(t => t.ToDomainObject()) .OrderBy(t => t.TimePeriod.StartDateTime) .ThenBy(t => t.Id) .ToArray(); list.Add(dto); } }); try { return(list.OrderBy(i => i.WorkingTimes.Any(t => t.IsDoing) ? 0 : 1) .ThenByDescending(i => i.WorkingTimes.Where(t => t.TimePeriod.IsFuture == false).Any() ? i.WorkingTimes.Where(t => t.TimePeriod.IsFuture == false).Max(t => t.TimePeriod.StartDateTime) : DateTime.MinValue) .ThenBy(i => i.WorkingTimes.Where(t => t.TimePeriod.IsFuture).Any() ? i.WorkingTimes.Where(t => t.TimePeriod.IsFuture).Min(t => t.TimePeriod.StartDateTime) : DateTime.MaxValue) .ThenBy(i => i.TaskId.Value).ToArray()); } catch (Exception) { return(list.ToArray()); } }
public void CreerClientOK() { Controleur controller = new CommandeControleur(); ClientDao client = new ClientDao(); int un = client.Clients.Count(); controller.CreerClient("DINDELEUX", "César", "*****@*****.**"); Assert.AreEqual(controller.GetClients().Last().Id, un + 1); // Vérifier que l'ID est bien augmenté de 1. Assert.AreEqual(controller.GetClients().Last().Nom, "DINDELEUX"); // Vérifier que le nom est bien inséré et correct Assert.AreEqual(controller.GetClients().Last().Prenom, "César"); // Vérifier que le prénom est bien inséré et correct Assert.AreEqual(controller.GetClients().Last().Mail, "*****@*****.**"); // Vérifier que le mail est bien inséré et correct Assert.AreEqual(controller.GetClients().Last().Commandes.Count(), 0); // Vérifier qu'à la création, ses commandes soient bien vides. }
public static Client GetClient(int id) { if (id >= 0) //existing user { return(ClientDao.Find(id)); } else if (id == -1) //new user or no user { return(new Client()); } return(null); }
private bool VerifyExistenceCpf(string cpf, Guid idClient) { bool returnResponse = true; Guid idClientDao = ClientDao.ClientExistsInTheContext(cpf); if (idClientDao != Guid.Empty && idClient.ToString().ToLower() != idClientDao.ToString().ToLower()) { httpStatus = HttpStatusCode.InternalServerError; replyMessage = "O Cpf informado já está cadastrado para outro usuário"; returnResponse = false; } return(returnResponse); }
/// <summary> /// MEtodo encargado de leer y grabar un archivo /// localmente /// </summary> /// <param name="contentPath"></param> /// <param name="registerPath"></param> /// <returns></returns> public Boolean ResolveClients(string contenFullName, string registerFullName, string pathResult) { if (!String.IsNullOrEmpty(contenFullName) && !String.IsNullOrEmpty(registerFullName) && !String.IsNullOrEmpty(pathResult)) { var clients = ClientDao.GetClients(registerFullName, Constants.SEPARETOR_FORMAT); var letters = LetterDao.GetLetters(contenFullName, Constants.SEPARETOR_FORMAT); if (clients != null && letters != null) { var clientResult = ResolveClientFromContent(clients, letters); return(SaveClients(clientResult, pathResult)); } } return(false); }
public void TestAddClient() { ClientEntity client = new ClientEntity(); client.Username = "******"; client.Password = "******"; client.RealName = "yangtf"; client.Role = new RoleDao().getByName("client"); client.Department = new DepartmentDao().getByName("6"); client.encryptPassword(); ClientDao clientDao = new ClientDao(); clientDao.save(client); }
public Client[] SelectAll() { var list = new List <Client>(); RepositoryAction.Query(c => { var listRow = new ClientDao(c, null).SelectAll(); list.AddRange(listRow.Select(r => r.ToDomainObject())); }); return(list.OrderBy(i => i.KanaName) .ThenBy(i => i.Id.Value) .ToArray()); }
public void TestAjoutClientOk() { Controleur c = new CommandeControleur(); ClientDao client = new ClientDao(); int unclient = client.Clients.Count(); c.AjouterClient("Gaborit", "Joan", "*****@*****.**"); Assert.AreEqual(c.GetClients().Last().Id, unclient + 1); Assert.AreEqual(c.GetClients().Last().Nom, "Gaborit"); Assert.AreEqual(c.GetClients().Last().Prenom, "Joan"); Assert.AreEqual(c.GetClients().Last().Mail, "*****@*****.**"); //J'ajoute un client avec un nom, un prénom et une adresse mail et je vérifie si le dernier client ajouté est bien égal aux informations //concernant l'ajout du client }
public void Film_Location_Transaction() { FilmDao film_dao = new FilmDao(); ClientDao client_dao = new ClientDao(); Client result_client = client_dao.GetClientParCourrielEtMotDePasse("*****@*****.**", "hello123"); Film f1 = film_dao.GetFilmParId(1); int check1 = film_dao.GetNbCopiesRestantes(f1.Id); film_dao.LouerCopie(f1.Id, result_client.Id); int check2 = film_dao.GetNbCopiesRestantes(f1.Id); Assert.AreEqual(check1 - 1, check2); }
public void TestVaidClient() { ClientDao dao = new ClientDao(); ClientEntity client = dao.getClientByUsername("admin_k6"); if (client != null) { Assert.IsTrue(dao.validClient(client, "1234")); } else { Assert.Fail(); } }
public void Client_Connection(string mdp, string email, bool expected_value) { ClientDao sut = new ClientDao(); Client result_client = sut.GetClientParCourrielEtMotDePasse(email, mdp); bool result; if (result_client == null) { result = false; } else { result = true; } Assert.AreEqual(result, expected_value); }