Example #1
0
        public async Task <OrderItemDTO> CreateNewOrderItem(OrderItem orderItem)
        {
            _context.OrderItem.Add(orderItem);

            await _context.SaveChangesAsync();

            return(await GetOneOrderItem(orderItem.Id));
        }
Example #2
0
        public async Task <StoreModifierDTO> SaveNewModifier(StoreModifier modifier, int storeId)
        {
            var newModifier = new StoreModifier
            {
                ModifierId  = modifier.ModifierId,
                Name        = modifier.Name,
                Description = modifier.Description,
                StoreId     = modifier.StoreId
            };

            _context.StoreModifier.Add(newModifier);

            await _context.SaveChangesAsync();

            var modifierToRetun = await GetOneModifier(storeId, modifier.ModifierId);

            return(modifierToRetun);
        }
        public async Task <StoreDTO> DeleteStore(int id)
        {
            var store = await _context.Store.FindAsync(id);

            if (store == null)
            {
                return(null);
            }

            var storeToReturn = await GetOneStore(id);

            _context.Store.Remove(store);


            await _context.SaveChangesAsync();

            return(storeToReturn);
        }
        public async Task <bool> UpdateOrder(int id, Orders order)
        {
            _context.Entry(order).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderExists(id))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
        }
        public async Task <ItemModifierDTO> AddNewItemModifier(int itemId, ItemModifier itemModifier)
        {
            var newIM = new ItemModifier
            {
                ItemId         = itemId,
                ModifierId     = itemModifier.ModifierId,
                AdditionalCost = itemModifier.AdditionalCost
            };

            _context.itemModifier.Add(newIM);
            await _context.SaveChangesAsync();


            var newIMDTO = new ItemModifierDTO
            {
                ModifierName   = "new",
                AdditionalCost = itemModifier.AdditionalCost
            };

            return(newIMDTO);
        }