Esempio n. 1
0
        public void DeleteDishFromOrder(int orderId, int dishId)
        {
            BestallningMatratt order = _context.BestallningMatratts.SingleOrDefault(o => o.BestallningId == orderId && o.MatrattId == dishId);

            int price = _context.Matratts.SingleOrDefault(d => d.MatrattId == dishId).Pris;

            Bestallning fullOrder = _context.Bestallnings.SingleOrDefault(fo => fo.BestallningId == orderId);

            fullOrder.Totalbelopp -= price * order.Antal;

            _context.Bestallnings.Update(fullOrder);


            _context.BestallningMatratts.Remove(order);
            _context.SaveChanges();
        }
Esempio n. 2
0
        public Bestallning GetUserOrder(string userId)
        {
            Bestallning order = _context.Bestallnings.SingleOrDefault(o => o.KundId == userId && o.Bekraftad == false && o.Levererad == false);

            return(order);
        }