Exemple #1
0
        public static Person Login(string mailInserted, string passwordInserted)
        {
            var mail     = mailInserted;
            var password = passwordInserted;
            var checkEmailAvailabilityResult = DbQuery.GetPeopleByMail(mail);

            if (checkEmailAvailabilityResult != null)
            {
                if (checkEmailAvailabilityResult.Count > 0)
                {
                    //Debug.WriteLine("Tem n linhas:"+ checkEmailAvailabilityResult.Count);
                    var adapter = new DictionaryAdapter(checkEmailAvailabilityResult[0]);
                    if (adapter.GetValue(DbQuery.PasswordProperty).Equals(password))
                    {
                        var exhibitorResult = DbQuery.GetExhibitorByPersonId(adapter.GetValue("id"));

                        Person user;
                        if (exhibitorResult.Count > 0)
                        {
                            user = new Exhibitor(exhibitorResult[0]);
                        }
                        else
                        {
                            var userData = DbQuery.GetEmployeeByPersonId(adapter.GetValue("id"));
                            user = new Employee(userData[0]);
                        }

                        return(user);
                    }

                    Console.WriteLine(@"Falta preencher coisas!!!!");
                    return(null);
                }
                else
                {
                    Console.WriteLine(@"Falta preencher coisas!!!!");
                    return(null);
                }
            }

            return(null);
        }
Exemple #2
0
        public void GetMessages()
        {
            var l = DbQuery.GetPeopleMessage(Id.ToString());

            foreach (var dmessages in l) //dicionario com as msgs
            {
                var dam      = new DictionaryAdapter(dmessages);
                var senderId = dam.GetValue("sender_id");
                if (senderId != null)
                {
                    var li = DbQuery.GetPeopleById(senderId);
                    Debug.WriteLine("l:" + l.Count + "li:" + li.Count);
                    foreach (var dperson in li) //dicionario com a pessoa dessa msg
                    {
                        var dap = new DictionaryAdapter(dperson);
                        var did = dap.GetValue("id");

                        var sender = CheckRole(did);

                        var msg             = new Message(dmessages, sender);
                        var dictad          = new DictionaryAdapter(dmessages);
                        var containsMessage = false;
                        foreach (var message in Messages)
                        {
                            if (message.Id == int.Parse(dictad.GetValue("id"))
                                ) // se ja existir essa msg nas messages da pessoa
                            {
                                containsMessage = true;
                            }
                        }
                        if (containsMessage == false) // se a msg nao existir adiciona-a
                        {
                            Messages.Insert(0, msg);
                        }
                    }
                }
            }
        }