Exemplo n.º 1
0
        // POST api/user
        public void Post(user user)
        {
            dbUserDataContext db = new dbUserDataContext();

            db.users.InsertOnSubmit(user);
            db.SubmitChanges();
        }
Exemplo n.º 2
0
        // DELETE api/user/5
        public void Delete(int id)
        {
            dbUserDataContext db = new dbUserDataContext();
            user tmp             = db.users.SingleOrDefault(p => p.id == id);

            db.users.DeleteOnSubmit(tmp);
            db.SubmitChanges();
        }
Exemplo n.º 3
0
        // PUT api/user/5
        public void Put(int id, user user)
        {
            dbUserDataContext db = new dbUserDataContext();
            user tmp             = db.users.SingleOrDefault(p => p.id == id);

            tmp.firstname = user.firstname;
            tmp.lastname  = user.lastname;
            tmp.age       = user.age;

            db.SubmitChanges();
        }