public CruiseModel GetCruiseById(int cruiseId) { using (var db = new OceanbnbDbEntities()) { return(cruiseMapper.Map <CruiseModel>(db.Cruises_GetById(cruiseId).SingleOrDefault())); } }
public UsersToCruisesModel InsertCruiseUser(int userId, int cruiseId) { using (var db = new OceanbnbDbEntities()) { return(userToCruiseMapper.Map <UsersToCruisesModel>(db.UsersToCruises_InsertUpdate(userId, cruiseId, false).SingleOrDefault())); } }
public ShipModel GetShipById(int shipId) { using (var db = new OceanbnbDbEntities()) { return(mapper.Map <ShipModel>(db.Ships_GetById(shipId).SingleOrDefault())); } }
public LocationModel GetLocationById(int locationId) { using (var db = new OceanbnbDbEntities()) { return(mapper.Map <LocationModel>(db.Locations_GetById(locationId).SingleOrDefault())); } }
public bool UpdateLocationToCruise(int locationId, int cruiseId, bool isDeleted) { using (var db = new OceanbnbDbEntities()) { var id = db.LocationsToCruises_InsertUpdate(locationId, cruiseId, isDeleted).SingleOrDefault(); return(true); } }
public LocationModel DeleteLocation(int locationId) { using (var db = new OceanbnbDbEntities()) { var id = db.Locations_Delete(locationId); return(mapper.Map <LocationModel>(db.Locations_GetById(locationId).SingleOrDefault())); } }
public LocationModel UpdateLocaiton(int locationId, string locationName, double lattitude, double longitude) { using (var db = new OceanbnbDbEntities()) { db.Locations_Update(locationId, locationName, lattitude, longitude).SingleOrDefault(); return(mapper.Map <LocationModel>(db.Locations_GetById(locationId).SingleOrDefault())); } }
public LocationsToCruisesModel DeleteLocationToCruise(int locationToCruiseId) { using (var db = new OceanbnbDbEntities()) { var id = db.LocationsToCruises_Delete(locationToCruiseId).SingleOrDefault(); return(locationToCruiseMapper.Map <LocationsToCruisesModel>(db.LocationsToCruises_GetById(int.Parse(id.ToString())).SingleOrDefault())); } }
public bool UpdateCruiseUser(int userId, int cruiseId, bool isDeleted) { using (var db = new OceanbnbDbEntities()) { db.UsersToCruises_InsertUpdate(userId, cruiseId, isDeleted).SingleOrDefault(); return(true); } }
public ShipModel InsertShip(string shipName, int yearBuilt, int passengerCapacity, int crewCount, int weightInTons, int lengthInMeters, int beamInMeters) { using (var db = new OceanbnbDbEntities()) { var id = db.Ships_Insert(shipName, yearBuilt, passengerCapacity, crewCount, weightInTons, lengthInMeters, beamInMeters).SingleOrDefault(); return(mapper.Map <ShipModel>(db.Ships_GetById(int.Parse(id.ToString())).SingleOrDefault())); } }
public CruiseModel UpdateCruise(int cruiseId, string cruiseName, int shipId) { using (var db = new OceanbnbDbEntities()) { db.Cruises_Update(cruiseId, cruiseName, shipId).SingleOrDefault(); return(cruiseMapper.Map <CruiseModel>(db.Cruises_GetById(cruiseId).SingleOrDefault())); } }
public ShipModel UpdateShip(int shipId, string shipName, int yearBuilt, int passengerCapacity, int crewCount, int weightInTons, int lengthInMeters, int beamInMeters) { using (var db = new OceanbnbDbEntities()) { var id = db.Ships_Update(shipId, shipName, yearBuilt, passengerCapacity, crewCount, weightInTons, lengthInMeters, beamInMeters).SingleOrDefault(); return(mapper.Map <ShipModel>(db.Ships_GetById(shipId).SingleOrDefault())); } }
public LocationsToCruisesModel InsertLocationToCruise(int locationId, int cruiseId) { using (var db = new OceanbnbDbEntities()) { var id = db.LocationsToCruises_InsertUpdate(locationId, cruiseId, false).SingleOrDefault(); return(locationToCruiseMapper.Map <LocationsToCruisesModel>(db.LocationsToCruises_GetById(int.Parse(id.ToString())).SingleOrDefault())); } }
public LocationModel InsertLocation(string locationName, double lattitude, double longitude) { using (var db = new OceanbnbDbEntities()) { var id = db.Locations_Insert(locationName, lattitude, longitude).SingleOrDefault(); return(mapper.Map <LocationModel>(db.Locations_GetById(int.Parse(id.ToString())).SingleOrDefault())); } }
public CruiseModel InsertCruise(string cruiseName, int shipId) { using (var db = new OceanbnbDbEntities()) { var id = db.Cruises_Insert(cruiseName, shipId).SingleOrDefault(); return(cruiseMapper.Map <CruiseModel>(db.Cruises_GetById(int.Parse(id.ToString())).SingleOrDefault())); } }
public List <ShipModel> GetAllShips() { using (var db = new OceanbnbDbEntities()) { var config = new MapperConfiguration(cfg => cfg.CreateMap <Ships_GetAllShips_Result, ShipModel>()); var mapper = config.CreateMapper(); return(mapper.Map <List <Ships_GetAllShips_Result>, List <ShipModel> >(db.Ships_GetAllShips().ToList())); } }
public List <CruiseModel> GetAllCruises() { using (var db = new OceanbnbDbEntities()) { var config = new MapperConfiguration(cfg => cfg.CreateMap <Cruises_GetAllCruises_Result, CruiseModel>()); var map = config.CreateMapper(); return(map.Map <List <Cruises_GetAllCruises_Result>, List <CruiseModel> >(db.Cruises_GetAllCruises().ToList())); } }
public UserModel GetUser(int id) { using (var db = new OceanbnbDbEntities()) { Users_GetById_Result userResult = db.Users_GetById(id).SingleOrDefault(); return(new UserModel(userResult.UserId, userResult.UserName, userResult.Email, userResult.Gender, userResult.City, userResult.Description, userResult.ProfilePhoto, userResult.AspUserId, userResult.IsDeleted)); } }
public List <CruiseUsersModel> GetCruiseUsers(int cruiseId) { using (var db = new OceanbnbDbEntities()) { var config = new MapperConfiguration(cfg => cfg.CreateMap <UsersToCruises_GetCruiseUsers_Result, CruiseUsersModel>()); var mapper = config.CreateMapper(); return(mapper.Map <List <UsersToCruises_GetCruiseUsers_Result>, List <CruiseUsersModel> >(db.UsersToCruises_GetCruiseUsers(cruiseId).ToList())); } }
public UserModel Update(int id, string userName, string email, string gender, string city, string description, string profilePhoto, string aspUserId) { using (var db = new OceanbnbDbEntities()) { db.Users_Update(id, userName, email, gender, city, description, profilePhoto).SingleOrDefault(); Users_GetById_Result userResult = db.Users_GetById(id).SingleOrDefault(); return(new UserModel(userResult.UserId, userResult.UserName, userResult.Email, userResult.Gender, userResult.City, userResult.Description, userResult.ProfilePhoto, userResult.AspUserId, userResult.IsDeleted)); } }
public UserModel GetUserByIdentityId(string aspUserId) { using (var db = new OceanbnbDbEntities()) { Users_GetByAspId_Result userResult = db.Users_GetByAspId(aspUserId).SingleOrDefault(); var config = new MapperConfiguration(cfg => cfg.CreateMap <Users_GetByAspId_Result, UserModel>()); var mapper = config.CreateMapper(); UserModel userModel = mapper.Map <UserModel>(userResult); userModel.AspUserId = aspUserId; return(userModel); } }
public CruiseModel GetFullCruiseById(int cruiseId) { using (var db = new OceanbnbDbEntities()) { var locationConfig = new MapperConfiguration(cfg => cfg.CreateMap <LocationsToCruises_GetCruiseLocations_Result, LocationModel>()); var locationMapper = locationConfig.CreateMapper(); Cruises_GetById_Result cruiseResult = db.Cruises_GetById(cruiseId).SingleOrDefault(); CruiseModel cruise = cruiseMapper.Map <CruiseModel>(cruiseResult); List <LocationModel> locations = locationMapper.Map <List <LocationsToCruises_GetCruiseLocations_Result>, List <LocationModel> >(db.LocationsToCruises_GetCruiseLocations(cruiseId).ToList()); cruise.LocationsList = locations; return(cruise); } }