private void BindAddressDetails() { using (AddressRepository repository = new AddressRepository()) { AddressDetails address = repository.Get(_AddressId); if (address != null) { txtAddress.Value = address.Address; txtDirection.Value = address.Direction; txtLandmark.Value = address.Landmark; txtPincode.Value = address.Pincode; txtOther.Value = address.OtherAddress == "NA" ? string.Empty : address.OtherAddress; ddlArea.SelectedValue = address.AreaId.ToString(); ddlCity.SelectedValue = address.CityId.ToString(); ddlCountry.SelectedValue = address.CountryId.ToString(); switch (address.AddressTypeId) { case (int)EnumAddressType.Home: rbtHome.Checked = true; rbtOffice.Checked = false; rbtOther.Checked = false; liOther.Style["display"] = "none"; break; case (int)EnumAddressType.Office: rbtHome.Checked = false; rbtOffice.Checked = true; rbtOther.Checked = false; liOther.Style["display"] = "inline"; break; case (int)EnumAddressType.Other: rbtHome.Checked = false; rbtOffice.Checked = false; rbtOther.Checked = true; liOther.Style["display"] = "inline"; break; } switch (address.IsDefault) { case true: rbtYes.Checked = true; rbtNo.Checked = false; break; case false: rbtYes.Checked = false; rbtNo.Checked = true; break; } } } }
// methode api pour fair le lien a mon repository Get public Address Get(int id) { AddressRepository serviceGet = new AddressRepository(); Address p = serviceGet.Get(id).Map <Address>(); if (p == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(p); }
public Address Get(int id) { try { return(IncludeCity(_addressRepo.Get(id).ToBLL())); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task Get_ReturnsNonExpiredAttributes() { const string nowString = "10/31/2018 10:54:30"; const int refreshAfterDays = 10; var address = new Address { Number = 123, Street = "MAIN", Tag = "ST", Attributes = new List <AddressAttribute> { // 11 days old. Expired. new AddressAttribute { Source = "PVA", VerificationTime = DateTime.Parse("10/20/2018 10:00:00"), AttributeName = "owner", AttributeValue = "JOHN DOE" }, // 10 days old. Expired. new AddressAttribute { Source = "PVA", VerificationTime = DateTime.Parse("10/21/2018 10:00:00"), AttributeName = "owner", AttributeValue = "JANE DOE" }, // 9 days old, but not the newest. new AddressAttribute { Source = "PVA", VerificationTime = DateTime.Parse("10/22/2018 10:00:00"), AttributeName = "owner", AttributeValue = "SAM DOE" }, // 9 days old, should be used. new AddressAttribute { Source = "PVA", VerificationTime = DateTime.Parse("10/22/2018 10:00:01"), AttributeName = "owner", AttributeValue = "JUDY DOE" } } }; var options = new DbContextOptionsBuilder <LouisvilleDemographicsContext>() .UseInMemoryDatabase(databaseName: "Test_Address_Attribute_Expiration") .Options; var louisvilleDemographicsContext = new LouisvilleDemographicsContext(options); louisvilleDemographicsContext.Addresses.Add(address); louisvilleDemographicsContext.SaveChanges(); var pvaSettings = new PvaSettings { RefreshAfterDays = refreshAfterDays }; var timeService = new Mock <ITimeService>(); timeService.SetupGet(t => t.Now).Returns(DateTime.Parse(nowString)); var addressRepository = new AddressRepository(null, louisvilleDemographicsContext, pvaSettings, timeService.Object); var result = await addressRepository.Get(address.Number, address.Direction, address.Street, address.Tag); Assert.Equal("JUDY DOE", result.Owner); }
public IHttpActionResult Get(int id) { BaseUrl = Request.RequestUri.Scheme + "://" + Request.RequestUri.Host + ":" + Request.RequestUri.Port; var address = addressRepo.Get(id); if (address == null) { return(StatusCode(HttpStatusCode.NoContent)); } address.Links = address.CreateLinks(BaseUrl); return(Ok(address)); }
public void Get_InvalidAddress() { var addressRepo = new AddressRepository(); var actualAddress = addressRepo.Get(0); Assert.True(actualAddress.AddressId == 0); Assert.True(actualAddress.AddressType == 0); Assert.True(string.IsNullOrEmpty(actualAddress.StreetLineOne)); Assert.True(string.IsNullOrEmpty(actualAddress.City)); Assert.True(string.IsNullOrEmpty(actualAddress.Country)); }
/// <summary> /// Delete profile address /// </summary> /// <param name="profileAddress"></param> public void DeleteProfileAddress(ProfileAddress profileAddress) { var address = _addressRepository.Get(profileAddress.AddressId); if (address != null) { _profileAddressRepository.Remove(profileAddress); _profileAddressRepository.UnitOfWork.Commit(); _addressRepository.Remove(address); _addressRepository.UnitOfWork.Commit(); } else { LoggerFactory.CreateLog().LogWarning(Messages.warning_CannotRemoveNonExistingAddress); } }
public void ShouldReturnOneAddressWhenGetByIdInFakeDataBase() { var addressId = _fakeContext.Addreses.FirstOrDefault().Id; var address = _addressRepository.Get(addressId); Assert.AreEqual("02123044", address.ZipCode); Assert.AreEqual(AddressType.Billing, address.Type); Assert.AreEqual("Travessa Gaspar Raposo", address.Street); Assert.AreEqual("Jardim Japão", address.Neighborhood); Assert.AreEqual("São Paulo", address.City); Assert.AreEqual("SP", address.State); Assert.IsTrue(address.CustomerId != Guid.Empty); }
/// <summary> /// Delete profile address /// </summary> /// <param name="profileId"></param> public void DeleteProfileAddress(ProfileAddress profileAddress) { var address = _addressRepository.Get(profileAddress.AddressId); if (address != null) //if address exist { _profileAddressRepository.Remove(profileAddress); //commit changes _profileAddressRepository.UnitOfWork.Commit(); _addressRepository.Remove(address); //commit changes _addressRepository.UnitOfWork.Commit(); } else //the customer not exist, cannot remove { LoggerFactory.CreateLog().LogWarning(Messages.warning_CannotRemoveNonExistingProfile); } }
public void Get_ValidAddress() { var addressRepo = new AddressRepository(); var expectedAddress = new Address(1) { AddressType = 2, StreetLineOne = "place1", Postcode = "LS11", City = "Leeds", Country = "UK" }; var actualAddress = addressRepo.Get(1); Assert.AreEqual(expectedAddress.AddressId, actualAddress.AddressId); Assert.AreEqual(expectedAddress.AddressType, actualAddress.AddressType); Assert.AreEqual(expectedAddress.StreetLineOne, actualAddress.StreetLineOne); Assert.AreEqual(expectedAddress.City, actualAddress.City); Assert.AreEqual(expectedAddress.Country, actualAddress.Country); }
public List <RequiredInformation> GetInformation(string connectionString) { List <Address> addresses = new List <Address>(); AddressRepository addressRepository = new AddressRepository(); addresses = addressRepository.Get(connectionString); List <Contact> contacts = new List <Contact>(); ContactRepository contactRepository = new ContactRepository(); contacts = contactRepository.Get(connectionString); List <Phone> phones = new List <Phone>(); PhoneRepository phoneRepository = new PhoneRepository(); phones = phoneRepository.Get(connectionString); List <PersonData> personsData = new List <PersonData>(); PersonDataRepository personData = new PersonDataRepository(); personsData = personData.Get(connectionString); List <Email> emails = new List <Email>(); EmailRepository emailRepository = new EmailRepository(); emails = emailRepository.Get(connectionString); List <RequiredInformation> information = new List <RequiredInformation>(); for (int i = 0; i < addresses.Count; i++) { RequiredInformation required = new RequiredInformation(); required.Address = addresses[i].PersonAddress; required.Contact = contacts[i].Name; required.Email = emails[i].EmailAddress; required.PhoneNumber = phones[i].PhoneNumber; required.LastName = personsData[i].LastName; required.FirstName = personsData[i].FirstName; information.Add(required); } return(information); }
protected void LogIn_ServerClick(object sender, EventArgs e) { try { int type = rbtHome.Checked ? 1 : rbtOffice.Checked ? 2 : 3; EnumAddressType addressType = (EnumAddressType)type; int userId = UserRepository.GetUserId(); bool isDefault = rbtYes.Checked ? true : false; using (AddressRepository addressRepository = new AddressRepository()) { if (_AddressId > 0) // Edit mode { AddressDetails address = addressRepository.Get(_AddressId); if (address != null) { address.UserId = userId; address.Address = txtAddress.Value.Trim(); address.Landmark = txtLandmark.Value.Trim(); address.Direction = txtDirection.Value.Trim(); address.CityId = Convert.ToInt32(ddlCity.SelectedValue.Trim()); address.AreaId = Convert.ToInt32(ddlArea.SelectedValue.Trim()); address.CountryId = Convert.ToInt32(ddlCountry.SelectedValue.Trim()); address.Pincode = txtPincode.Value.Trim(); address.AddressTypeId = (int)addressType; if (rbtOffice.Checked || rbtOther.Checked) { address.OtherAddress = txtOther.Value.Trim(); } else { address.OtherAddress = "NA"; } // if IsDefault is true then make other false. if (isDefault) { addressRepository.MakeOtherfalse(userId); } address.IsDefault = isDefault; addressRepository.Update(); Response.Redirect("~/Apps/User/AddressBookList.aspx?fg=2"); //SuccessMessage.Visible = true; //SuccessMessage.Text = "Address has been updated successfully."; } } else // Add mode { if (!addressRepository.GetAddressAlreadyExistsOrNot(userId, type)) { AddressDetails newAddress = new AddressDetails(); newAddress.UserId = userId; newAddress.Address = txtAddress.Value.Trim(); newAddress.Landmark = txtLandmark.Value.Trim(); newAddress.Direction = txtDirection.Value.Trim(); newAddress.CityId = Convert.ToInt32(ddlCity.SelectedValue.Trim()); newAddress.AreaId = Convert.ToInt32(ddlArea.SelectedValue.Trim()); newAddress.CountryId = Convert.ToInt32(ddlCountry.SelectedValue.Trim()); newAddress.Pincode = txtPincode.Value.Trim(); newAddress.AddressTypeId = (int)addressType; if (rbtOffice.Checked || rbtOther.Checked) { newAddress.OtherAddress = txtOther.Value.Trim(); } else { newAddress.OtherAddress = "NA"; } // if IsDefault is true then make other false. if (isDefault) { addressRepository.MakeOtherfalse(userId); } newAddress.IsDefault = isDefault; addressRepository.Add(newAddress); Response.Redirect("~/Apps/User/AddressBookList.aspx?fg=1"); //SuccessMessage.Visible = true; //SuccessMessage.Text = "New address has been added successfully."; } else { ErrorMessage.Visible = true; ErrorMessage.Text = "Address is already exists !!"; } } } } catch (Exception ex) { ErrorMessage.Visible = true; ErrorMessage.Text = ex.Message.ToString(); } }
public Address Get(int id) { return(_repo.Get(id)); }
public async Task <DTOAddress> GetAddress(int id) { Address address = await _addressRepository.Get(id); return(_mapper.Map <DTOAddress>(address)); }