Exemplo n.º 1
0
        public ActionResult <SweetTartTart> UpdateItem([FromRoute] int id, [FromBody] SweetTartTart item)
        {
            // i need to update the item text, complete, and updated at
            var candy = db.TartItems.FirstOrDefault(f => f.Id == id);

            candy.SKU              = item.SKU;
            candy.Name             = item.Name;
            candy.ShortDescription = item.ShortDescription;
            candy.NumberInStock    = item.NumberInStock;
            candy.Price            = item.Price;
            candy.LocationId       = item.LocationId;
            db.SaveChanges();
            return(candy);
        }
Exemplo n.º 2
0
        public ActionResult <SweetTartTart> Post([FromBody] SweetTartTart tartitem, [FromQuery] int locationId)
        {
            // get the user that has teh access token
            var location = db.Locations.FirstOrDefault(l => l.Id == locationId);

            if (location == null)
            {
                // if the user doesnt exist, make it
                location = new Location
                {
                    Id = locationId
                };
                db.Locations.Add(location);
                db.SaveChanges();
            }
            // set the the item.UserId = user.id
            // somethingGoofy.UserId = user.Id;
            // db.ToDoItems.Add(somethingGoofy);

            location.Items.Add(tartitem);

            db.SaveChanges();
            return(tartitem);
        }