public IHttpActionResult GetRoomType(int id) { RoomType roomType = db.RoomTypes.Find(id); if (roomType == null) { return(NotFound()); } return(Ok(ViewModelMapper.ToViewModelRoomTypes(roomType))); }
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))); }
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))); }
// GET: api/RoomTypes public List <RoomTypeViewModel> GetRoomTypes() { return(db.RoomTypes.ToList().Select(x => ViewModelMapper.ToViewModelRoomTypes(x)).ToList()); }