Example #1
0
        public async Task <IActionResult> PutFloor(int id, Floor floor)
        {
            if (id != floor.Id)
            {
                return(BadRequest());
            }

            FloorValid valid = new FloorValid(_context, floor);

            if (valid.Valid() == false)
            {
                return(BadRequest("This Floor is already exist"));
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <ActionResult <Floor> > PostFloor(Floor floor)
        {
            FloorValid valid = new FloorValid(_context, floor);

            if (valid.Valid() == false)
            {
                return(BadRequest("This floor is already exist"));
            }
            _context.Floor.Add(floor);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFloor", new { id = floor.Id }, floor));
        }