public void UpdateAddressNoContentFailureTest() { int id = 1; string Address1 = "Test"; string Address2 = "Test"; string City = "Test"; string ZipCode = "Test"; bool isDeleted = false; int AddressTypeId = 1; int CreatedByUserId = 1; NSI.REST.Models.AddressEditModel address = new AddressEditModel() { Address1 = Address1, Address2 = Address2, City = City, ZipCode = ZipCode, IsDeleted = isDeleted, AddressTypeId = AddressTypeId, DateModified = DateTime.Now }; var addressRepo = new Mock <IAddressRepository>(); addressRepo.Setup(x => x.EditAddress(It.IsAny <int>(), It.IsAny <AddressDto>())); var addressManipulation = new AddressManipulation(addressRepo.Object); var controller = new AddressController(addressManipulation); var result = controller.PutAddress(1, address); Assert.IsType <NoContentResult>(result); }
private Organization GetDomainforOrganizationCreateModel(long id, out AddressEditModel billingAddress, out AddressEditModel businessAddress, out File teamImage, out File logoImage) { Organization organization = _organizationRepository.GetOrganizationbyId(id); GetAssociatesforCreateModel(organization, out billingAddress, out businessAddress, out teamImage, out logoImage); return(organization); }
private void GetAssociatesforCreateModel(Organization organization, out AddressEditModel billingAddress, out AddressEditModel businessAddress, out File teamImage, out File logoImage) { billingAddress = businessAddress = null; teamImage = logoImage = null; if (organization.BillingAddressId > 0) { billingAddress = Mapper.Map <Address, AddressEditModel>(_addressRepository.GetAddress(organization.BillingAddressId)); } if (organization.BusinessAddressId > 0) { businessAddress = Mapper.Map <Address, AddressEditModel>(_addressRepository.GetAddress(organization.BusinessAddressId)); } if (organization.LogoImageId > 0) { logoImage = _fileRepository.GetById(organization.LogoImageId); } if (organization.TeamImageId > 0) { teamImage = _fileRepository.GetById(organization.TeamImageId); } }
private OrganizationEditModel BuildOrganizationCreateModel() { var organizationCreateModel = new OrganizationEditModel(); organizationCreateModel.Name = txtbname.Text; organizationCreateModel.OrganizationType = OrganizationType.CallCenter; organizationCreateModel.Description = txtabtmself.Text; var businessAddress = new AddressEditModel(); businessAddress.StreetAddressLine1 = txtaddress1.Text; businessAddress.StreetAddressLine2 = string.Empty; businessAddress.CountryId = CountryId;//new CountryRepository().GetById(Convert.ToInt32(hfBusinessCountryID.Value)).Name; businessAddress.StateId = Convert.ToInt32(ddlstate1.SelectedItem.Value); businessAddress.City = txtBuCity.Text; businessAddress.ZipCode = txtzip1.Text; organizationCreateModel.BusinessAddress = businessAddress; //Have to remove this organizationCreateModel.PhoneNumber = new PhoneNumber() { Number = txtbphone.Text }.ToNumber(); organizationCreateModel.FaxNumber = new PhoneNumber() { Number = txtbfax.Text }.ToNumber(); return(organizationCreateModel); }
public async Task <IActionResult> EditAddress(AddressEditModel model, long addressId) { var customer = await HttpContext.GetMemberAsync(); var addresses = await _addressService.ListAsync(new AddressFilter { CustomerId = customer.Id }); var address = addresses.FirstOrDefault(x => x.Id == addressId); if (address == null) { return(NotFound()); } if (HttpMethods.IsGet(Request.Method)) { ModelState.Clear(); await _appService.PrepareModelAsync(model, address); } else if (HttpMethods.IsPost(Request.Method)) { if (ModelState.IsValid) { await _appService.PrepareAddressAsync(address, model); await _addressService.UpdateAsync(address); await _addressService.ResolveAddressTypesAsync(address, addresses); TempData.AddAlert(AlertMode.Notify, AlertType.Success, "Address was updated."); } } return(PartialView("AddressEdit", model)); }
public IActionResult PutAddress(int id, [FromBody] AddressEditModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } AddressDto addressDto = new AddressDto() { Address1 = model.Address1, Address2 = model.Address2, City = model.City, ZipCode = model.ZipCode, AddressTypeId = model.AddressTypeId, DateModified = DateTime.Now, IsDeleted = (bool)model.IsDeleted }; try { if (AddressRepository.EditAddress(id, addressDto)) { return(Ok()); } return(NoContent()); } catch (Exception ex) { return(BadRequest(ex.InnerException)); } }
public UserEditModel() { IsLocked = false; Address = new AddressEditModel(); TechnicianProfile = new TechnicianModel(); PhysicianProfile = new PhysicianModel(); AccountCoordinatorProfile = new AccountCoordinatorProfileModel(); }
public Task PrepareAddressAsync(Address address, AddressEditModel model) { if (address == null) { throw new ArgumentNullException(nameof(address)); } if (model == null) { throw new ArgumentNullException(nameof(model)); } address = _mapper.Map(model, address); return(Task.CompletedTask); }
public ActionResult EditAddress(AddressEditModel model) { if (ModelState.IsValid) { if (addressServices.EditAddress(model)) { return(RedirectToAction("Address")); } return(HttpNotFound()); } else { return(View(model)); } }
public void ValidatorValidatesCorrectlyWhenAddressIsEmpty() { AddressEditModel addressEditModel = new AddressEditModel(); var validationResult = _validator.Validate(addressEditModel); //foreach (var error in validationResult.Errors) //{ // Console.WriteLine("Property Name : {0}, Error Message: {1}", error.PropertyName, error.ErrorMessage); //} Assert.AreEqual(false, validationResult.IsValid); var expectedErrors = 10; Assert.AreEqual(expectedErrors, validationResult.Errors.Count); }
public OrganizationEditModel ToModel(Organization organization, AddressEditModel billingAddress, AddressEditModel businessAddress, File logoImage, File teamImage) { return(new OrganizationEditModel() { BillingAddress = billingAddress ?? new AddressEditModel(), BusinessAddress = businessAddress ?? new AddressEditModel(), Description = organization.Description, Email = organization.Email, FaxNumber = organization.FaxNumber, Id = organization.Id, LogoImage = logoImage, Name = organization.Name, OrganizationType = organization.OrganizationType, PhoneNumber = organization.PhoneNumber, TeamImage = teamImage }); }
public Task PrepareModelAsync(AddressEditModel model, Address address) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (address != null) { model = _mapper.Map(address, model); } else { } return(Task.CompletedTask); }
public MedicalVendorEditModel ToModel(MedicalVendor organization, AddressEditModel billingAddress, AddressEditModel businessAddress, File logoImage, File teamImage, PaymentInstructions instructions, TestPayRate[] payRates, decimal customerPayRate, TestType[] permitted) { var binder = new OrganizationCreateModelBinder(); var model = new MedicalVendorEditModel(); model = binder.ToModel(model, organization, billingAddress, businessAddress, logoImage, teamImage) as MedicalVendorEditModel; model.ContractId = organization.ContractId; model.MedicalVendorType = organization.MedicalVendorType; model.IsHospitalPartner = organization.IsHospitalPartner; //model.CustomerPayRate = customerPayRate; //model.EvaluationMode = organization.EvaluationMode; //model.PaymentInstructions = instructions; //model.PermittedTests = permitted; //model.TestPayRates = payRates; return(model); }
public async Task <IActionResult> AddAddress(AddressEditModel model, AddressType?addressType) { var customer = await HttpContext.GetMemberAsync(); if (HttpMethods.IsGet(Request.Method)) { ModelState.Clear(); if (addressType != null) { model.AddressTypes.Add(addressType.Value); } // Set predefined values when adding a new address. model.FirstName = customer.FirstName; model.LastName = customer.LastName; model.Email = customer.Email; model.PhoneNumber = customer.PhoneNumber; model.Organization = customer.StoreName; await _appService.PrepareModelAsync(model, null); } else if (HttpMethods.IsPost(Request.Method)) { if (ModelState.IsValid) { var addresses = await _addressService.ListAsync(new AddressFilter { CustomerId = customer.Id }); var address = new Address(); await _appService.PrepareAddressAsync(address, model); address.CustomerId = customer.Id; await _addressService.CreateAsync(address); await _addressService.ResolveAddressTypesAsync(address, addresses); TempData.AddAlert(AlertMode.Notify, AlertType.Success, "Address was added."); } } return(PartialView("AddressEdit", model)); }
public bool EditAddress(AddressEditModel model) { try { var entity = unitOfwork.AddressRepo.Get(x => x.Id.Equals(model.AddressId)).FirstOrDefault(); entity.AddressLine1 = model.AddressLine1; entity.AddressLine2 = model.AddressLine2; entity.AddressMap = model.AddressMap; entity.AreaCode = model.AreaCode; entity.State = model.State; entity.Suburb = model.Suburb; entity.Status = model.Status; unitOfwork.AddressRepo.Update(entity); return(unitOfwork.Save() > 0); } catch (Exception) { throw; } }
public async Task <ApiResult> Edit(AddressEditModel model) { if (string.IsNullOrEmpty(model.Name)) { return(new ApiResult { status = 0, msg = "收货人姓名不能为空" }); } if (string.IsNullOrEmpty(model.Mobile)) { return(new ApiResult { status = 0, msg = "收货人手机号不能为空" }); } if (!Regex.IsMatch(model.Mobile, @"^1\d{10}$")) { return(new ApiResult { status = 0, msg = "收货人手机号格式不正确" }); } if (string.IsNullOrEmpty(model.Address)) { return(new ApiResult { status = 0, msg = "收货人地址不能为空" }); } bool flag = await addressService.UpdateAsync(model.Id, model.Name, model.Mobile, model.Address, model.IsDefault); if (!flag) { return(new ApiResult { status = 0, msg = "收货地址修改失败" }); } return(new ApiResult { status = 1, msg = "收货地址修改成功" }); }
public IActionResult Edit(int addressId) { //TODO: Make it so, only users can edit their address Address address = this.addressesService.GetAddress(addressId); if (address == null) { return(this.NotFound()); } AddressEditModel model = new AddressEditModel { Id = address.Id, AdditionalInformation = address.AdditionalInformation, City = address.City, Country = address.Country, Postcode = address.Postcode, Street = address.Street }; return(this.View(model)); }
public ProcessorResponse ApplyRefundtoNewCard(decimal amountToRefund, Name customerName, ChargeCard card, AddressEditModel address, string ipAddress, string cardProcessingUniqueId, string email)// Should use Address DO in place of Model { return (_paymentProcessor.RefundRequestOnOtherCreditCard( GetCreditCardProcesingInfo(amountToRefund > 0 ? (-1 * amountToRefund) : amountToRefund, customerName, card, address, ipAddress, cardProcessingUniqueId, email))); }
public OnlineCustomerPersonalInformationEditModel GetCustomerInfo(string guid) { var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid); var model = new OnlineCustomerPersonalInformationEditModel { RequestValidationModel = onlineRequestValidationModel }; if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid) { return(model); } var shippingAddress = new AddressEditModel() { StreetAddressLine1 = OnlineAddress1, City = _onlineCity, StateId = _onlineStateId, CountryId = _onlineCountryId, ZipCode = _onlineZip }; model.CustomerEditModel = new SchedulingCustomerEditModel { EnableTexting = _enableTexting, EnableVoiceMail = _enableVoiceMail, ShippingAddress = shippingAddress }; var tempCart = onlineRequestValidationModel.TempCart; var customer = tempCart.CustomerId.HasValue ? _customerRepository.GetCustomer(tempCart.CustomerId.Value) : null; if (customer == null && tempCart.ProspectCustomerId.HasValue && tempCart.ProspectCustomerId.Value > 0) { model.CustomerEditModel = _prospectCustomerService.GetforProspectCustomerId(tempCart.ProspectCustomerId.Value); if (model.CustomerEditModel.ShippingAddress.StreetAddressLine1 == OnlineAddress1) { model.CustomerEditModel.ShippingAddress = shippingAddress; } } else if (customer != null) { model.CustomerEditModel = Mapper.Map <Customer, SchedulingCustomerEditModel>(customer); model.CustomerEditModel.ShippingAddress = Mapper.Map <Address, AddressEditModel>(customer.Address); model.CustomerEditModel.ConfirmationToEnablTexting = customer.EnableTexting; model.CustomerEditModel.ConfirmationToEnableVoiceMail = customer.EnableVoiceMail; } model.CustomerEditModel.EnableTexting = _enableTexting; model.CustomerEditModel.EnableVoiceMail = _enableVoiceMail; model.CustomerEditModel.MarketingSource = tempCart.MarketingSource; if (tempCart.Dob.HasValue && !model.CustomerEditModel.DateofBirth.HasValue) { model.CustomerEditModel.DateofBirth = tempCart.Dob.Value; } if (!string.IsNullOrEmpty(tempCart.Gender) && !(model.CustomerEditModel.Gender.HasValue && model.CustomerEditModel.Gender.Value > 0)) { model.CustomerEditModel.Gender = (int)((Gender)System.Enum.Parse(typeof(Gender), tempCart.Gender, true)); } if (tempCart.EventId.HasValue && tempCart.EventId.Value > 0) { var eventData = _eventRepository.GetById(tempCart.EventId.Value); if (eventData.AccountId.HasValue && eventData.AccountId.Value > 0) { var account = _corporateAccountRepository.GetbyEventId(tempCart.EventId.Value); model.CustomerEditModel.InsuranceIdLabel = (account != null && !string.IsNullOrEmpty(account.MemberIdLabel)) ? account.MemberIdLabel : string.Empty; } model.CustomerEditModel.InsuranceIdRequired = eventData.InsuranceIdRequired; var eventHospitalPartner = _hospitalPartnerRepository.GetEventHospitalPartnersByEventId(tempCart.EventId.Value); if (eventHospitalPartner != null) { model.CustomerEditModel.CaptureSsn = eventHospitalPartner.CaptureSsn; } } //model.ShippingOptions = _onlineShippingService.GetShippingOption(tempCart); return(model); }
public MassRegistrationEditModel() { Address = new AddressEditModel(); }
public IActionResult Edit(AddressEditModel model) { this.addressesService.EditAddress(model.Country, model.City, model.Street, model.AdditionalInformation, model.Postcode, model.Id); return(this.Redirect("/Addresses/")); }
public OrganizationEditModel ToModel(OrganizationEditModel model, Organization organization, AddressEditModel billingAddress, AddressEditModel businessAddress, File logoImage, File teamImage) { model.BillingAddress = billingAddress; model.BusinessAddress = businessAddress; model.Description = organization.Description; model.Email = organization.Email; model.FaxNumber = organization.FaxNumber; model.Id = organization.Id; model.LogoImage = logoImage; model.Name = organization.Name; model.OrganizationType = organization.OrganizationType; model.PhoneNumber = organization.PhoneNumber; model.TeamImage = teamImage; return(model); }
public ProcessorResponse ChargefromCard(decimal amountToCharge, Name customerName, ChargeCard card, AddressEditModel address, string ipAddress, string cardProcessingUniqueId, string email)// Should use Address DO in place of Model { return(_paymentProcessor.ChargeCreditCard(GetCreditCardProcesingInfo(amountToCharge, customerName, card, address, ipAddress, cardProcessingUniqueId, email))); }
//Yasir: This is really a factory method. june 10 2011 private CreditCardProcessorProcessingInfo GetCreditCardProcesingInfo(decimal amount, Name customerName, ChargeCard card, AddressEditModel address, string ipAddress, string cardProcessingUniqueId, string email)// Should use Address DO in place of Model { return(new CreditCardProcessorProcessingInfo { CreditCardNo = card.Number, SecurityCode = card.CVV, ExpiryMonth = card.ExpirationDate.Month, ExpiryYear = card.ExpirationDate.Year, CardType = card.TypeId.ToString(), Price = amount.ToString(), FirstName = customerName.FirstName, LastName = !string.IsNullOrEmpty(customerName.LastName) ? customerName.LastName : customerName.FirstName, BillingAddress = address.StreetAddressLine1, BillingCity = address.City, BillingState = _stateRepository.GetState(address.StateId).Code, BillingPostalCode = address.ZipCode, BillingCountry = _countryRepository.GetCountryCode(address.CountryId), Email = string.IsNullOrEmpty(email)?_settings.SupportEmail.ToString():email, IpAddress = ipAddress, Currency = "USD", OrderId = cardProcessingUniqueId }); }
public OrganizationEditModel() { BusinessAddress = new AddressEditModel(); BillingAddress = new AddressEditModel(); }
private FranchiseeEditModel SetFranchiseeData(FranchiseeEditModel franchiseeEditModel) { if (franchiseeEditModel == null) { franchiseeEditModel = new FranchiseeEditModel(); } franchiseeEditModel.Name = txtFranchiseeName.Text; franchiseeEditModel.Description = txtDesciption.Text; var address = new AddressEditModel(); address.StreetAddressLine1 = txtbuaddress1.Text; address.StreetAddressLine2 = txtbuaddress2.Text; address.CountryId = _countryId; if (ddlBuState.SelectedIndex > 0) { address.StateId = Convert.ToInt32(ddlBuState.SelectedItem.Value); } address.City = txtBuCity.Text; if (!string.IsNullOrEmpty(txtBuZip.Text)) { address.ZipCode = txtBuZip.Text; } if (!address.IsEmpty()) { if (franchiseeEditModel.BusinessAddress != null) { address.Id = franchiseeEditModel.BusinessAddress.Id; } franchiseeEditModel.BusinessAddress = address; } else { franchiseeEditModel.BusinessAddress = null; } if (!chkBiAddress.Checked) { address = new AddressEditModel(); address.StreetAddressLine1 = txtBiAddress1.Text; address.StreetAddressLine2 = txtBiAddress2.Text; address.CountryId = _countryId; if (ddlBiState.SelectedIndex > 0) { address.StateId = Convert.ToInt32(ddlBiState.SelectedItem.Value); } address.City = txtBiCity.Text; if (!string.IsNullOrEmpty(txtBiZip.Text)) { address.ZipCode = txtBiZip.Text; } if (!address.IsEmpty()) { if (franchiseeEditModel.BillingAddress != null) { address.Id = franchiseeEditModel.BillingAddress.Id; } franchiseeEditModel.BillingAddress = address; } else { franchiseeEditModel.BillingAddress = null; } } else { address.Id = 0; if (franchiseeEditModel.BillingAddress != null) { address.Id = franchiseeEditModel.BillingAddress.Id; } franchiseeEditModel.BillingAddress = address; } franchiseeEditModel.FaxNumber = new PhoneNumber() { Number = txtBuFax.Text }; franchiseeEditModel.PhoneNumber = new PhoneNumber() { Number = txtBuPhone.Text }; var pods = new List <Pod>(); foreach (ListItem item in PodCheckboxList.Items) { pods.Add(new Pod(Convert.ToInt64(item.Value))); } franchiseeEditModel.AllocatedPods = pods.ToArray(); return(franchiseeEditModel); }
public OnSiteRegistrationEditModel() { Address = new AddressEditModel(); }
private MedicalVendorEditModel SetMedicalVendorData(MedicalVendorEditModel medicalVendorEditModel) { if (medicalVendorEditModel == null) { medicalVendorEditModel = new MedicalVendorEditModel(); } medicalVendorEditModel.OrganizationEditModel.Name = txtVendorName.Text; medicalVendorEditModel.OrganizationEditModel.Description = DescriptionTextbox.Text; medicalVendorEditModel.ContractId = Convert.ToInt64(ddlContracts.SelectedItem.Value); //medicalVendorEditModel.EvaluationMode = EvaluationMode.Customer; // This is default for the time being //medicalVendorEditModel.CustomerPayRate = Convert.ToDecimal(txtPayRateCustomer.Text); medicalVendorEditModel.MedicalVendorType = Convert.ToInt32(ddlVendorType.SelectedValue); medicalVendorEditModel.IsHospitalPartner = chkHospitalPartner.Checked; #region "Setting Addresses" var address = new AddressEditModel(); address.StreetAddressLine1 = txtAddress1.Text; address.StreetAddressLine2 = txtAddress2.Text; address.CountryId = _countryId; if (ddlState.SelectedIndex > 0) { address.StateId = Convert.ToInt32(ddlState.SelectedItem.Value); } address.City = txtCity.Text; if (!string.IsNullOrEmpty(txtZip.Text)) { address.ZipCode = txtZip.Text; } if (!address.IsEmpty()) { if (medicalVendorEditModel.OrganizationEditModel.BusinessAddress != null) { address.Id = medicalVendorEditModel.OrganizationEditModel.BusinessAddress.Id; } medicalVendorEditModel.OrganizationEditModel.BusinessAddress = address; } else { medicalVendorEditModel.OrganizationEditModel.BusinessAddress = null; } if (!chkBiAddress.Checked) { address = new AddressEditModel(); address.StreetAddressLine1 = txtBiAddress1.Text; address.StreetAddressLine2 = txtBiAddress2.Text; address.CountryId = _countryId; if (ddlBiState.SelectedIndex > 0) { address.StateId = Convert.ToInt32(ddlBiState.SelectedItem.Text); } address.City = txtBiCity.Text; if (!string.IsNullOrEmpty(txtBiZip.Text)) { address.ZipCode = txtBiZip.Text; } if (!address.IsEmpty()) { if (medicalVendorEditModel.OrganizationEditModel.BillingAddress != null) { address.Id = medicalVendorEditModel.OrganizationEditModel.BillingAddress.Id; } medicalVendorEditModel.OrganizationEditModel.BillingAddress = address; } else { medicalVendorEditModel.OrganizationEditModel.BillingAddress = null; } } else { address.Id = 0; if (medicalVendorEditModel.OrganizationEditModel.BillingAddress != null) { address.Id = medicalVendorEditModel.OrganizationEditModel.BillingAddress.Id; } medicalVendorEditModel.OrganizationEditModel.BillingAddress = address; } #endregion medicalVendorEditModel.OrganizationEditModel.FaxNumber = new PhoneNumber() { Number = txtBusinessFax.Text }; medicalVendorEditModel.OrganizationEditModel.PhoneNumber = new PhoneNumber() { Number = txtBusinessPhone.Text }; //medicalVendorEditModel.PaymentInstructions = // SetMedicalVendorPaymentInstructions(medicalVendorEditModel.PaymentInstructions); var selectedItems = (from item in PermittedTestCheckboxList.Items.OfType <ListItem>() where item.Selected select(TestType) Convert.ToInt32(item.Value)).ToArray(); if (selectedItems.Length < 1) { ClientScript.RegisterStartupScript(typeof(string), "bijscode", "alert('Please select a test.');", true); return(null); } //medicalVendorEditModel.PermittedTests = selectedItems; return(medicalVendorEditModel); }