예제 #1
0
        public IHttpActionResult GetRoomType(int id)
        {
            RoomType roomType = db.RoomTypes.Find(id);

            if (roomType == null)
            {
                return(NotFound());
            }

            return(Ok(ViewModelMapper.ToViewModelRoomTypes(roomType)));
        }
예제 #2
0
        public IHttpActionResult PostRoomType(RoomTypeViewModel roomTypeViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            RoomType roomType = ViewModelMapper.ToModelRoomTypes(roomTypeViewModel);

            db.RoomTypes.Add(roomType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = roomType.RoomTypeId }, ViewModelMapper.ToViewModelRoomTypes(roomType)));
        }
예제 #3
0
        public IHttpActionResult DeleteRoomType(int id)
        {
            RoomType roomType = db.RoomTypes.Find(id);

            if (roomType == null)
            {
                return(NotFound());
            }

            db.RoomTypes.Remove(roomType);
            db.SaveChanges();

            return(Ok(ViewModelMapper.ToViewModelRoomTypes(roomType)));
        }
예제 #4
0
 // GET: api/RoomTypes
 public List <RoomTypeViewModel> GetRoomTypes()
 {
     return(db.RoomTypes.ToList().Select(x => ViewModelMapper.ToViewModelRoomTypes(x)).ToList());
 }