Beispiel #1
0
        public async Task <ActionResult <ConfRoomItem> > Post(ConfRoomItem TempItem)
        {
            bool check = _context.ConfRoomItems.Any(x => x.RoomNr == TempItem.RoomNr);

            if (check)
            {
                return(BadRequest(new { error = "This room is occupied already." }));
            }

            _context.ConfRoomItems.Add(TempItem);
            await _context.SaveChangesAsync();

            return(Ok(new { call = "Element successfully added." }));
        }
Beispiel #2
0
        public async Task <ActionResult <ConfRoomItem> > Put(long id, ConfRoomItem TempItem)
        {
            if (id != TempItem.Id)
            {
                return(BadRequest(new { error = "Wrong ID in url or file." }));
            }

            var FindID = await _context.ConfRoomItems.FindAsync(TempItem.Id);

            if (FindID == null)
            {
                return(NotFound(new { error = "No element with such ID found in database." }));
            }

            _context.Entry(TempItem).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(Ok(new { call = "Element successfully updated." }));
        }
Beispiel #3
0
        public async Task <ActionResult <ConfRoomItem> > Patch(long id, ConfRoomItem TempItem)
        {
            // Patch implementation

            return(NotFound(new { error = "Implement method." }));
        }