Example #1
0
        public async Task <ActionResult <ShelfSetup> > PostShelfSetup(ShelfSetup shelfSetup)
        {
            if (shelfSetup == null)
            {
                return(BadRequest());
            }
            shelfSetup.CreatedDate = System.DateTime.Now;
            context.ShelfSetup.Save(shelfSetup);
            await context.Save();

            var newlyAdded = await context.ShelfSetup.GetRelatedData(shelfSetup.Id);

            return(newlyAdded);
        }
Example #2
0
        public async Task <ActionResult <ShelfSetup> > UpdateShelfSetup(int id, ShelfSetup shelfSetup)
        {
            var result = await context.ShelfSetup.GetFirstOrDefault(item => item.Id == id);

            if (result == null)
            {
                return(NotFound());
            }
            result.BookId        = shelfSetup.BookId;
            result.ShelfCreateId = shelfSetup.ShelfCreateId;
            result.UpdatedDate   = System.DateTime.Now;
            await context.Save();

            var returnObject = await context.ShelfSetup.GetRelatedData(id);

            return(returnObject);
        }