Ejemplo n.º 1
0
 public void CreateWish(Wish wish)
 {
     using (WishContext ctx = new WishContext())
     {
         ctx.Wish.Add(wish);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void CreateUser(User user)
 {
     using (WishContext ctx = new WishContext())
     {
         ctx.Usuarios.Add(user);
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        public void EditUser(User user)
        {
            using (WishContext ctx = new WishContext())
            {
                var userSearch = ctx.Usuarios.Where(x => x.Id == user.Id).FirstOrDefault();

                userSearch.Email = user.Email;
                userSearch.Nome  = user.Nome;
                userSearch.Senha = user.Senha;

                ctx.Usuarios.Update(userSearch);
                ctx.SaveChanges();
            }
        }
        public IActionResult Create([FromBody] Wishlist wishlist)
        {
            if (wishlist.Name == "" || wishlist.Name == null || !ModelState.IsValid) // Any other bad inputs?
            {
                return(BadRequest());
            }

            // Default the password to an empty string
            wishlist.Password ??= "";
            // Set the owner Id to the current user id
            string userId = HttpContext.User.Claims.ElementAt(0).Value;

            wishlist.OwnerId = userId;
            _db.Wishlists.Add(wishlist);
            _db.SaveChanges();
            return(CreatedAtRoute("GetOne", new { id = wishlist.Id }, wishlist));
        }
Ejemplo n.º 5
0
 public void Add(Model.Wish W)
 {
     _dbContext.Wishes.Add(W);
     _dbContext.SaveChanges();
 }