public async Task <IHttpActionResult> GetStation(int id) { IStationDao stationDao = AdoFactory.Instance.GetStationDao("wetr"); IAddressDao addressDao = AdoFactory.Instance.GetAddressDao("wetr"); ICommunityDao communitDao = AdoFactory.Instance.GetCommunityDao("wetr"); IDistrictDao districtDao = AdoFactory.Instance.GetDistrictDao("wetr"); IProvinceDao provinceDao = AdoFactory.Instance.GetProvinceDao("wetr"); ICountryDao countryDao = AdoFactory.Instance.GetCountryDao("wetr"); Station myStations = await stationDao.FindByIdAsync(id); if (myStations == null) { return(Content(HttpStatusCode.BadRequest, new object())); } StationDTO station = new StationDTO(myStations); station.CommunityId = (await addressDao.FindByIdAsync(station.AddressId)).CommunityId; station.DistrictId = (await communitDao.FindByIdAsync(station.CommunityId)).DistrictId; station.ProvinceId = (await districtDao.FindByIdAsync(station.DistrictId)).ProvinceId; station.CountryId = (await provinceDao.FindByIdAsync(station.ProvinceId)).CountryId; station.Location = (await addressDao.FindByIdAsync(station.AddressId)).Location; return(Content(HttpStatusCode.OK, station)); }
public RepositoryUser(IConnectionFactory connectionFactory) : base(connectionFactory) { _roleDao = DaoFactory.CreateRoleDao(); _userDao = DaoFactory.CreateUserDao(); _addressDao = DaoFactory.CreateAddressDao(); _cityDao = DaoFactory.CreateCityDao(); }
public AddressHistoryService(IAddressDao dao, ICommandBus commandBus, IAccountDao accountDao, IOrderDao orderDao) { _dao = dao; _commandBus = commandBus; _accountDao = accountDao; _orderDao = orderDao; }
public async Task <IHttpActionResult> GetMyStations() { string token = Request.Headers.GetValues("Authorization").FirstOrDefault(); int userId = JwtHelper.Instance.GetUserId(token); IStationDao stationDao = AdoFactory.Instance.GetStationDao("wetr"); IAddressDao addressDao = AdoFactory.Instance.GetAddressDao("wetr"); ICommunityDao communitDao = AdoFactory.Instance.GetCommunityDao("wetr"); IDistrictDao districtDao = AdoFactory.Instance.GetDistrictDao("wetr"); IProvinceDao provinceDao = AdoFactory.Instance.GetProvinceDao("wetr"); ICountryDao countryDao = AdoFactory.Instance.GetCountryDao("wetr"); IEnumerable <Station> myStations = null; myStations = await stationDao.FindByUserIdAsync(userId); List <StationDTO> convertedStations = new List <StationDTO>(); /* Infer location ids for convenience */ foreach (var s in myStations) { StationDTO station = new StationDTO(s); station.CommunityId = (await addressDao.FindByIdAsync(station.AddressId)).CommunityId; station.DistrictId = (await communitDao.FindByIdAsync(station.CommunityId)).DistrictId; station.ProvinceId = (await districtDao.FindByIdAsync(station.DistrictId)).ProvinceId; station.CountryId = (await provinceDao.FindByIdAsync(station.ProvinceId)).CountryId; station.Location = (await addressDao.FindByIdAsync(station.AddressId)).Location; convertedStations.Add(station); } return(Content(HttpStatusCode.OK, convertedStations)); }
public AddressManager(ICountryDao countryDao, IProvinceDao provinceDao, IDistrictDao districtDao, ICommunityDao communityDao, IAddressDao addressDao ) { this.countryDao = countryDao; this.communityDao = communityDao; this.provinceDao = provinceDao; this.districtDao = districtDao; this.addressDao = addressDao; }
public async Task <IHttpActionResult> EditStationAsync(StationDTO station) { /* Check if model is valid */ if (!ModelState.IsValid) { var errors = ModelState.ToDictionary( kvp => kvp.Key, kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray() ); return(Content(HttpStatusCode.BadRequest, errors)); } string token = Request.Headers.GetValues("Authorization").FirstOrDefault(); int userId = JwtHelper.Instance.GetUserId(token); IStationDao stationDao = AdoFactory.Instance.GetStationDao("wetr"); Station stationToEdit = await stationDao.FindByIdAsync(station.StationId); /* If the station doesn't belong to the user */ if (stationToEdit.UserId != userId) { return(Content(HttpStatusCode.Forbidden, new object())); } /* Create new address */ IAddressDao addressDao = AdoFactory.Instance.GetAddressDao("wetr"); await addressDao.UpdateAsync(new Address() { AddressId = stationToEdit.AddressId, CommunityId = station.CommunityId, Location = station.Location, Zip = "NO_ZIP" }); int newAddressId = Convert.ToInt32((await addressDao.GetNextId()) - 1); station.AddressId = newAddressId; /* Edit Station */ await stationDao.UpdateAsync(station.ToStation()); return(Content(HttpStatusCode.OK, new object())); }
public async Task <IHttpActionResult> CreateStation(StationDTO station) { /* Check if model is valid */ if (!ModelState.IsValid) { var errors = ModelState.ToDictionary( kvp => kvp.Key, kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray() ); return(Content(HttpStatusCode.BadRequest, errors)); } string token = Request.Headers.GetValues("Authorization").FirstOrDefault(); int userId = JwtHelper.Instance.GetUserId(token); IStationDao stationDao = AdoFactory.Instance.GetStationDao("wetr"); IAddressDao addressDao = AdoFactory.Instance.GetAddressDao("wetr"); await addressDao.InsertAsync(new Address() { CommunityId = station.CommunityId, Location = station.Location, Zip = "NO_ZIP" }); int newAddressId = Convert.ToInt32((await addressDao.GetNextId()) - 1); /* Cleanup */ station.AddressId = newAddressId; station.StationId = 0; station.UserId = userId; await stationDao.InsertAsync(station.ToStation()); return(Content(HttpStatusCode.OK, new object())); }
public async Task <IHttpActionResult> GetStations(int communityId) { IStationDao stationDao = AdoFactory.Instance.GetStationDao("wetr"); IAddressDao addressDao = AdoFactory.Instance.GetAddressDao("wetr"); ICommunityDao communitDao = AdoFactory.Instance.GetCommunityDao("wetr"); IDistrictDao districtDao = AdoFactory.Instance.GetDistrictDao("wetr"); IProvinceDao provinceDao = AdoFactory.Instance.GetProvinceDao("wetr"); ICountryDao countryDao = AdoFactory.Instance.GetCountryDao("wetr"); IEnumerable <Station> stations = null; stations = await stationDao.FindAllAsync(); List <StationDTO> convertedStations = new List <StationDTO>(); /* Infer location ids for convenience */ foreach (var s in stations) { StationDTO station = new StationDTO(s); station.CommunityId = (await addressDao.FindByIdAsync(station.AddressId)).CommunityId; station.DistrictId = (await communitDao.FindByIdAsync(station.CommunityId)).DistrictId; station.ProvinceId = (await districtDao.FindByIdAsync(station.DistrictId)).ProvinceId; station.CountryId = (await provinceDao.FindByIdAsync(station.ProvinceId)).CountryId; station.Location = (await addressDao.FindByIdAsync(station.AddressId)).Location; convertedStations.Add(station); } if (communityId != 0) { convertedStations.RemoveAll(s => s.CommunityId != communityId); } return(Content(HttpStatusCode.OK, convertedStations)); }
public AddressBaseMgr(IAddressDao entityDao) { this.entityDao = entityDao; }
public AddressLogic(IAddressDao <Address> iAddressDao, IValidateLogic <Address> IValidateLogic) { addressDao = iAddressDao ?? throw new ArgumentNullException($"{nameof(iAddressDao)} is null!"); validateLogic = IValidateLogic ?? throw new ArgumentNullException($"{nameof(IValidateLogic)} is null!"); }
public AddressLogic(IAddressDao addressDao) { this._addressDao = addressDao; }
public AddressMgr(IAddressDao entityDao, ICriteriaMgr criteriaMgr) : base(entityDao) { this.criteriaMgr = criteriaMgr; }
public AddressesService(IAddressDao dao) { Dao = dao; }
public AddressController(IAddressDao addressDao) { _addressDao = addressDao; }
static Dependencies() { addressDao = new AddressDaoDb(); addressValidateLogic = new AddressValidateLogic(); AddressLogic = new AddressLogic(addressDao, addressValidateLogic); }
public LocationManager(ILocationDao locationDao, IAddressDao addressDao) { _locationDao = locationDao; _addressDao = addressDao; }
public AddressManager(IAddressDao addressDao) { _addressDao = addressDao; }