コード例 #1
0
        //PUT
        public void UpdateUser(User user)
        {
            using (WalkAboutDb dc = new WalkAboutDb())
            {
                var CurUser = (from a in dc.Users
                               where a.UsrId == user.UsrId
                               select a).FirstOrDefault();
                CurUser.Fname = user.Fname;
                CurUser.Lname = user.Lname;
                CurUser.CurrentCity = user.CurrentCity;
                dc.SaveChanges();

            }
        }
コード例 #2
0
        // POST
        public void AddUser(User user)
        {
            using (WalkAboutDb dc = new WalkAboutDb())
            {
                User usr = new User {
                 UsrId = user.UsrId ,
                 Fname = user.Fname ,
                 Lname = user.Lname ,
                 CurrentCity = user.CurrentCity

                };

                dc.Users.Add(usr);
                dc.SaveChanges();

            }
        }
コード例 #3
0
        //Post Category
        public void AddCategory(Category category)
        {
            using (WalkAboutDb dc = new WalkAboutDb())
            {
                Category cat = new Category
                {

                    CatId = category.CatId,
                    CategoryName = category.CategoryName,
                    IconNameLocal = category.IconNameLocal

                };

                dc.Categories.Add(cat);
                dc.SaveChanges();
            }
        }
コード例 #4
0
        //handles updates
        //Put Category
        public Category UpdateCategory(Category category)
        {
            using (WalkAboutDb dc = new WalkAboutDb())
            {

               //get the current category

                var CurCat = (from a in dc.Categories
                              where a.CatId == category.CatId
                              select a).FirstOrDefault ();

                //perform update
                CurCat.CategoryName = category.CategoryName;
                CurCat.IconNameLocal = category.IconNameLocal;
                //persist to dbase
                dc.SaveChanges();

                return CurCat;
            }
        }