Esempio n. 1
0
        public void CreatePostSubcategory(int newPostId, int subcatagoryId)
        {
            TexasListContext db        = new TexasListContext();
            PostSubcategory  newSubCat = db.PostSubcategories.Create();

            newSubCat.PostId        = newPostId;
            newSubCat.SubcategoryId = subcatagoryId;
            db.PostSubcategories.Add(newSubCat);
            db.SaveChanges();
        }
Esempio n. 2
0
        public int DeletePost(int deleteId)
        {
            TexasListContext db = new TexasListContext();
            int userId;

            Post editPost = db.Posts.Where(p => p.PostId == deleteId).First();

            userId = editPost.UserId;
            db.Posts.Remove(editPost);
            db.SaveChanges();

            return(userId);
        }
Esempio n. 3
0
        public int CreateUser(string UserName, string Email)
        {
            TexasListContext db      = new TexasListContext();
            User             newUser = db.Users.Create();

            newUser.UserName = UserName;
            newUser.Email    = Email;

            db.Users.Add(newUser);
            db.SaveChanges();

            int newId = newUser.UserId;

            return(newId);
        }
Esempio n. 4
0
        public int CreatePost(string title, string adBody, string amount, int userId, int subcatagoryId, int cityId)
        {
            TexasListContext db = new TexasListContext();

            Subcategory catHolder = db.Subcategories.Where(c => c.SubcategoryId == subcatagoryId).First();

            Post newPost = db.Posts.Create();

            newPost.Title      = title;
            newPost.AdBody     = adBody;
            newPost.Amount     = amount;
            newPost.UserId     = userId;
            newPost.CityId     = cityId;
            newPost.CategoryId = catHolder.CategoryId;

            db.Posts.Add(newPost);
            db.SaveChanges();

            return(newPost.PostId);
        }