public void CrudListen(string incomeMessage)
        {
            var packet = master.DecodePacket(incomeMessage);

            switch (packet.QueryType)
            {
            case "READ":
            {
                string reply        = master.CreateResponsePacket(dao.Read());
                byte[] replyMessage = Encoding.UTF8.GetBytes(reply);
                Reply(replyMessage, null);
                break;
            }

            case "CREATE":
            {
                dao.Create(packet.Persons[0]);
                break;
            }

            case "UPDATE":
            {
                dao.Update(packet.Persons[0]);
                break;
            }

            case "DELETE":
            {
                dao.Delete(packet.Persons[0]);
                break;
            }
            }
        }
        public void TestEmptyCreate(string actualPath, string expectedPath, int id, string fName, string lName, int age)
        {
            Person p = new Person(Convert.ToUInt32(id), fName, lName, Convert.ToUInt32(age));

            dao.ConnectionString = CurrentDirectory + actualPath + fileFormat;
            dao.Create(p);
            List <Person> actual = (List <Person>)dao.Read();

            using (StreamWriter fs = new StreamWriter(dao.ConnectionString))
            {
                fs.Write("");
            }

            dao.ConnectionString = CurrentDirectory + expectedPath + fileFormat;
            List <Person> expected = (List <Person>)dao.Read();

            PersonAssert(actual, expected);
        }
 public bool Create(ContactEditM contact)
 {
     try
     {
         Person person = ConverterContactToPerson.ForSave(contact);
         return(personDao.Create(person));
     }
     catch (Exception ex)
     {
         //TO DO logging
         return(false);
     }
 }
Exemple #4
0
        public string Reg(Person user)
        {
            LinkedList <Person> users = db.Read();

            foreach (Person record in users)
            {
                if (record.name == user.name)
                {
                    LogProvider.AppendRecord(string.Format("registered user exists [{0}]", user.name));
                    return("User exists");
                }
            }
            LogProvider.AppendRecord(string.Format("registered new user [{0}]", user.name));
            db.Create(user);
            return("You have registered");
        }
        private void CRUD_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            switch (btn.Text.ToUpper())
            {
            case "CREATE":
            {
                db.Create(GetPerson());
                break;
            }

            case "READ":
            {
                Person p = db.Read(Convert.ToInt32(etId.Text));
                SetPerson(p);
                break;
            }

            case "READ ALL":
            {
                List <Person>       p           = db.ReadAll().ToList();
                FragmentDAOView     fragment    = new FragmentDAOView(p);
                FragmentTransaction transaction = FragmentManager.BeginTransaction();
                transaction.Replace(Resource.Id.main_activity_frame, fragment);
                transaction.Commit();
                break;
            }

            case "UPDATE":
            {
                db.Update(GetPerson());
                break;
            }

            case "DELETE":
            {
                db.Delete(GetPerson());
                break;
            }

            default:
                break;
            }
        }
 public void Create(Person person)
 {
     db.Create(person);
 }
 public void Create(Person p)
 {
     dbActive.Create(p);
 }
Exemple #8
0
 public void Create(Person persona)
 {
     daoDB.Create(persona);
 }
Exemple #9
0
 public void Create(Person p)
 {
     dao.Create(p);
 }