Ejemplo n.º 1
0
        public async Task <IActionResult> PutOrder_ClientRoom(int id, Order_ClientRoom order_ClientRoom)
        {
            if (id != order_ClientRoom.Id)
            {
                return(BadRequest());
            }

            _context.Entry(order_ClientRoom).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Order_ClientRoomExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Order_ClientRoom> > PostOrder_ClientRoom(Order_ClientRoom order_ClientRoom)
        {
            var t = _context.Order_ClientRoom.ToList();

            foreach (var tt in t)
            {
                if (tt.ClientRoomId == order_ClientRoom.ClientRoomId && tt.OrderId == order_ClientRoom.OrderId)
                {
                    return(BadRequest("you're not allowed to create duplicate records"));
                }
            }

            if (_context.Order_ClientRoom.Where(a => a.ClientRoomId == order_ClientRoom.ClientRoomId).Count() >= 5)
            {
                return(BadRequest("5 orders max"));
            }

            _context.Order_ClientRoom.Add(order_ClientRoom);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrder_ClientRoom", new { id = order_ClientRoom.Id }, order_ClientRoom));
        }