public override void Save(Affiliate entity) { using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) { base.Save(entity); scope.Complete(); } }
public static void Main( ) { PixUser user = new PixUser(); Affiliate aff = new Affiliate(); user.userName ="******"; user.password ="******"; user.email = "*****@*****.**"; user.firstName ="net"; user.lastName = "user"; aff.userName ="******"; aff.password ="******"; aff.email = "*****@*****.**"; aff.firstName = "net"; aff.lastName = "affiliate"; aff.websiteURL = "http://netaffiliate.org"; aff.companyName = "dummyaff"; AffiliateManagmentServiceImpl proxy = new AffiliateManagmentServiceImpl(); WriteMessage("Invoking Affiliate Management Web Service."); try { //Registered Affiliate proxy.enrollAffiliate(aff); WriteMessage("Registered affiliate " + aff.companyName); proxy.enrollUserViaAffiliateWebSite(user,aff); WriteMessage("Enrolled user " + user.userName); } catch(Exception e) {Console.WriteLine("Threw general exception: {0}", e);} }
/// <summary> /// Récupère un lecteur par ses prénoms et noms. /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="AffToFill"></param> public static void GetAffiliateByName(string firstName, string lastName, ref Affiliate AffToFill) { using (SqlConnection connection = UtilsDAL.GetConnection()) { StringBuilder sLog = new StringBuilder(); try { using (SqlCommand command = new SqlCommand("SchAdmin.GetAffiliateByName", connection)) { Affiliate affTemp = new Affiliate(); SqlParameter param1 = new SqlParameter("@firstName", firstName); SqlParameter param2 = new SqlParameter("@lastName", lastName); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(param1); command.Parameters.Add(param2); sLog.Append("Open"); connection.Open(); SqlDataReader dtReader = command.ExecuteReader(); sLog.Append("Read"); while (dtReader.Read()) { affTemp.CardNum = dtReader.GetInt32(0); if (!dtReader.IsDBNull(1)) { affTemp.CardValidity = dtReader.GetDateTime(1); } // else affTemp.CardValidity = default(DateTime); affTemp.MainLibraryId = dtReader.GetInt32(2); affTemp.FirstName = dtReader.GetString(3); affTemp.LastName = dtReader.GetString(4); if (!dtReader.IsDBNull(5)) { affTemp.BirthDate = dtReader.GetDateTime(5); } } AffToFill = affTemp; } } catch (SqlException sqlEx) { sqlEx.Data.Add("Log", sLog); int DefaultSqlError = 6; //"Erreur SQL non traitée !" L'exception sera relancée. switch (sqlEx.Number) { case 4060: throw new EL.CstmError(1, sqlEx); //"Mauvaise base de données" case 18456: throw new EL.CstmError(2, sqlEx); //"Mauvais mot de passe" default: throw new EL.CstmError(DefaultSqlError, sqlEx); //"Erreur SQL non traitée !" L'exception sera relancée. } } catch (Exception ex) { int DefaultError = 7; //"Problème à la récupération des données!" throw new EL.CstmError(DefaultError, ex); } } }
public void UpdateAffiliate(ref Affiliate affiliate) { var proxy = _affiliateService.CreateProxy(); proxy.UpdateAffiliate(ref affiliate); }
protected virtual void PrepareAffiliateModel(AffiliateModel model, Affiliate affiliate, bool excludeProperties, bool prepareEntireAddressModel = true) { if (model == null) { throw new ArgumentNullException("model"); } if (affiliate != null) { model.Id = affiliate.Id; model.Url = affiliate.GenerateUrl(_webHelper); if (!excludeProperties) { model.AdminComment = affiliate.AdminComment; model.FriendlyUrlName = affiliate.FriendlyUrlName; model.Active = affiliate.Active; model.Address = affiliate.Address.ToModel(); } } if (prepareEntireAddressModel) { model.Address.FirstNameEnabled = true; model.Address.FirstNameRequired = true; model.Address.LastNameEnabled = true; model.Address.LastNameRequired = true; model.Address.EmailEnabled = true; model.Address.EmailRequired = true; model.Address.CompanyEnabled = true; model.Address.CountryEnabled = true; model.Address.StateProvinceEnabled = true; model.Address.CityEnabled = true; model.Address.CityRequired = true; model.Address.StreetAddressEnabled = true; model.Address.StreetAddressRequired = true; model.Address.StreetAddress2Enabled = true; model.Address.ZipPostalCodeEnabled = true; model.Address.ZipPostalCodeRequired = true; model.Address.PhoneEnabled = true; model.Address.PhoneRequired = true; model.Address.FaxEnabled = true; //address model.Address.AvailableCountries.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Address.SelectCountry"), Value = "" }); foreach (var c in _countryService.GetAllCountries(showHidden: true)) { model.Address.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString(), Selected = (affiliate != null && c.Id == affiliate.Address.CountryId) }); } var states = !String.IsNullOrEmpty(model.Address.CountryId) ? _stateProvinceService.GetStateProvincesByCountryId(model.Address.CountryId, showHidden: true).ToList() : new List <StateProvince>(); if (states.Count > 0) { foreach (var s in states) { model.Address.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString(), Selected = (affiliate != null && s.Id == affiliate.Address.StateProvinceId) }); } } else { model.Address.AvailableStates.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Address.OtherNonUS"), Value = "" }); } } }
/// <summary> /// Inserts an affiliate /// </summary> /// <param name="affiliate">Affiliate</param> /// <returns>A task that represents the asynchronous operation</returns> public virtual async Task InsertAffiliateAsync(Affiliate affiliate) { await _affiliateRepository.InsertAsync(affiliate); }
/// <summary> /// Prepare paged affiliated order list model /// </summary> /// <param name="searchModel">Affiliated order search model</param> /// <param name="affiliate">Affiliate</param> /// <returns>Affiliated order list model</returns> public virtual AffiliatedOrderListModel PrepareAffiliatedOrderListModel(AffiliatedOrderSearchModel searchModel, Affiliate affiliate) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (affiliate == null) { throw new ArgumentNullException(nameof(affiliate)); } //get parameters to filter orders var startDateValue = !searchModel.StartDate.HasValue ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.StartDate.Value, _dateTimeHelper.CurrentTimeZone); var endDateValue = !searchModel.EndDate.HasValue ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); var orderStatusIds = searchModel.OrderStatusId > 0 ? new List <int> { searchModel.OrderStatusId } : null; var paymentStatusIds = searchModel.PaymentStatusId > 0 ? new List <int> { searchModel.PaymentStatusId } : null; var shippingStatusIds = searchModel.ShippingStatusId > 0 ? new List <int> { searchModel.ShippingStatusId } : null; //get orders var orders = _orderService.SearchOrders(createdFromUtc: startDateValue, createdToUtc: endDateValue, osIds: orderStatusIds, psIds: paymentStatusIds, ssIds: shippingStatusIds, affiliateId: affiliate.Id, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new AffiliatedOrderListModel { //fill in model values from the entity Data = orders.Select(order => new AffiliatedOrderModel { Id = order.Id, OrderStatus = _localizationService.GetLocalizedEnum(order.OrderStatus), OrderStatusId = order.OrderStatusId, PaymentStatus = _localizationService.GetLocalizedEnum(order.PaymentStatus), ShippingStatus = _localizationService.GetLocalizedEnum(order.ShippingStatus), OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false), CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc), CustomOrderNumber = order.CustomOrderNumber }), Total = orders.TotalCount }; return(model); }
/// <summary> /// Prepare affiliated order search model /// </summary> /// <param name="searchModel">Affiliated order search model</param> /// <param name="affiliate">Affiliate</param> /// <returns>Affiliated order search model</returns> protected virtual AffiliatedOrderSearchModel PrepareAffiliatedOrderSearchModel(AffiliatedOrderSearchModel searchModel, Affiliate affiliate) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (affiliate == null) { throw new ArgumentNullException(nameof(affiliate)); } searchModel.AffliateId = affiliate.Id; //prepare available order, payment and shipping statuses _baseAdminModelFactory.PrepareOrderStatuses(searchModel.AvailableOrderStatuses); _baseAdminModelFactory.PreparePaymentStatuses(searchModel.AvailablePaymentStatuses); _baseAdminModelFactory.PrepareShippingStatuses(searchModel.AvailableShippingStatuses); //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
/// <summary> /// Prepare paged affiliated customer list model /// </summary> /// <param name="searchModel">Affiliated customer search model</param> /// <param name="affiliate">Affiliate</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the affiliated customer list model /// </returns> public virtual async Task <AffiliatedCustomerListModel> PrepareAffiliatedCustomerListModelAsync(AffiliatedCustomerSearchModel searchModel, Affiliate affiliate) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (affiliate == null) { throw new ArgumentNullException(nameof(affiliate)); } //get customers var customers = await _customerService.GetAllCustomersAsync(affiliateId : affiliate.Id, pageIndex : searchModel.Page - 1, pageSize : searchModel.PageSize); //prepare list model var model = new AffiliatedCustomerListModel().PrepareToGrid(searchModel, customers, () => { //fill in model values from the entity return(customers.Select(customer => { var affiliatedCustomerModel = customer.ToModel <AffiliatedCustomerModel>(); affiliatedCustomerModel.Name = customer.Email; return affiliatedCustomerModel; })); }); return(model); }
public virtual async Task <(IEnumerable <AffiliateModel.AffiliatedCustomerModel> affiliateCustomerModels, int totalCount)> PrepareAffiliatedCustomerList(Affiliate affiliate, int pageIndex, int pageSize) { var customers = await _customerService.GetAllCustomers( affiliateId : affiliate.Id, pageIndex : pageIndex - 1, pageSize : pageSize); return(customers.Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel(); customerModel.Id = customer.Id; customerModel.Name = customer.Email; return customerModel; }), customers.TotalCount); }
public virtual async Task <(IEnumerable <AffiliateModel.AffiliatedOrderModel> affiliateOrderModels, int totalCount)> PrepareAffiliatedOrderList(Affiliate affiliate, AffiliatedOrderListModel model, int pageIndex, int pageSize) { DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; ShippingStatus?shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null; var orders = await _orderService.SearchOrders( createdFromUtc : startDateValue, createdToUtc : endDateValue, os : orderStatus, ps : paymentStatus, ss : shippingStatus, affiliateId : affiliate.Id, pageIndex : pageIndex - 1, pageSize : pageSize); return(orders.Select(order => { var orderModel = new AffiliateModel.AffiliatedOrderModel(); orderModel.Id = order.Id; orderModel.OrderNumber = order.OrderNumber; orderModel.OrderCode = order.Code; orderModel.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); orderModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc); return orderModel; }), orders.TotalCount); }
public virtual async Task <Affiliate> UpdateAffiliateModel(AffiliateModel model, Affiliate affiliate) { affiliate.Active = model.Active; affiliate.AdminComment = model.AdminComment; //validate friendly URL name var friendlyUrlName = await affiliate.ValidateFriendlyUrlName(_affiliateService, _seoSettings, model.FriendlyUrlName); affiliate.FriendlyUrlName = friendlyUrlName; affiliate.Address = model.Address.ToEntity(affiliate.Address); await _affiliateService.UpdateAffiliate(affiliate); return(affiliate); }
/// <summary> /// Allows the REST API to create or update an affiliate /// </summary> /// <param name="parameters"> /// Parameters passed in the URL of the REST API call. If there is a first parameter found in the /// URL, the method will assume it is the affiliate ID and that this is an update, otherwise it assumes to create an /// affiliate. /// </param> /// <param name="querystring">Name/value pairs from the REST API call querystring. This is not used in this method.</param> /// <param name="postdata">Serialized (JSON) version of the AffiliateDTO object</param> /// <returns>AffiliateDTO - Serialized (JSON) version of the affiliate</returns> public override string PostAction(string parameters, NameValueCollection querystring, string postdata) { var data = string.Empty; var ids = FirstParameter(parameters); long id = 0; long.TryParse(ids, out id); var isReferrals = GetParameterByIndex(1, parameters); if (isReferrals.Trim().ToLowerInvariant() == "referrals") { // Create Referral var responseA = new ApiResponse <AffiliateReferralDTO>(); AffiliateReferralDTO postedItemA = null; try { postedItemA = Json.ObjectFromJson <AffiliateReferralDTO>(postdata); } catch (Exception ex) { responseA.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return(responseA.ObjectToJson()); } var itemA = new AffiliateReferral(); itemA.FromDto(postedItemA); HccApp.ContactServices.AffiliateReferrals.Create2(itemA, true); responseA.Content = itemA.ToDto(); data = responseA.ObjectToJson(); } else { // Create/Update Affiliate var responseB = new ApiResponse <AffiliateDTO>(); AffiliateDTO postedItem = null; try { postedItem = Json.ObjectFromJson <AffiliateDTO>(postdata); } catch (Exception ex) { responseB.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return(responseB.ObjectToJson()); } var item = new Affiliate(); item.FromDto(postedItem); if (id < 1) { var existing = HccApp.ContactServices.Affiliates.FindByAffiliateId(item.AffiliateId); if (existing == null || existing.Id < 1) { // 20140408 - Updated to call the current repository method, instead of allowing the error to be thrown var result = CreateUserStatus.None; try { // set a temporary password item.Password = PasswordGenerator.GeneratePassword(8); // create the affiliate HccApp.ContactServices.Affiliates.Create(item, ref result); } catch (Exception createException) { // return the exception to the calling method responseB.Errors.Add(new ApiError { Code = "EXCEPTION", Description = createException.Message }); } if (result == CreateUserStatus.Success) { // send the affiliate responseB.Content = item.ToDto(); } else { // send a response why the affiliate wasn't created responseB.Errors.Add(new ApiError { Code = "USERNOTCREATED", Description = result.ToString() }); } id = item.Id; } else { try { responseB.Content = existing.ToDto(); id = existing.Id; } catch (Exception exUpdate) { responseB.Errors.Add(new ApiError { Code = "EXCEPTION", Description = exUpdate.Message }); } } } else { try { HccApp.ContactServices.Affiliates.Update(item); } catch (Exception ex) { responseB.Errors.Add(new ApiError { Code = "EXCEPTION", Description = ex.Message }); } id = item.Id; responseB.Content = item.ToDto(); } data = responseB.ObjectToJson(); } return(data); }
// GET: Articles/Create public IActionResult Create() { var model = new Affiliate(); return(View(model)); }
public void SendAffiliateApplicationApproval(Affiliate affiliate) { _emailService.SendAffiliateApprovalEmail(affiliate); }
public void SendAffiliateApplicationRejection(Affiliate affiliate) { _emailService.SendAffiliateRejectionEmail(affiliate); }
public Affiliate SaveAffiliate(Affiliate affiliate) { _affiliateRepository.SaveOrUpdate(affiliate); return(affiliate); }
public void AddAffiliate(Affiliate product) { this.context.Affiliate.Add(product); }
public FormLect(MainForm parentForm) { InitializeComponent(); _parentForm = parentForm; _affiliate = _parentForm._CurrentAffiliate; }
public void UpdateAffiliate(Affiliate product) { this.context.Update(product); }
/// <summary> /// Prepare affiliated customer search model /// </summary> /// <param name="searchModel">Affiliated customer search model</param> /// <param name="affiliate">Affiliate</param> /// <returns>Affiliated customer search model</returns> protected virtual AffiliatedCustomerSearchModel PrepareAffiliatedCustomerSearchModel(AffiliatedCustomerSearchModel searchModel, Affiliate affiliate) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (affiliate == null) { throw new ArgumentNullException(nameof(affiliate)); } searchModel.AffliateId = affiliate.Id; //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
public void RemoveAffiliate(Affiliate product) { this.context.Affiliate.Remove(product); }
/// <summary> /// Prepare paged affiliated customer list model /// </summary> /// <param name="searchModel">Affiliated customer search model</param> /// <param name="affiliate">Affiliate</param> /// <returns>Affiliated customer list model</returns> public virtual AffiliatedCustomerListModel PrepareAffiliatedCustomerListModel(AffiliatedCustomerSearchModel searchModel, Affiliate affiliate) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (affiliate == null) { throw new ArgumentNullException(nameof(affiliate)); } //get customers var customers = _customerService.GetAllCustomers(affiliateId: affiliate.Id, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new AffiliatedCustomerListModel { //fill in model values from the entity Data = customers.Select(customer => new AffiliatedCustomerModel { Id = customer.Id, Name = customer.Email }), Total = customers.TotalCount }; return(model); }
public void SendAffiliateApprovalEmail(Affiliate affiliate) { _emailProvider.SendAffiliateRegister(affiliate.EmailAddress, affiliate.AffiliateCode); }
/// <summary> /// Marks affiliate as deleted /// </summary> /// <param name="affiliate">Affiliate</param> /// <returns>A task that represents the asynchronous operation</returns> public virtual async Task DeleteAffiliateAsync(Affiliate affiliate) { await _affiliateRepository.DeleteAsync(affiliate); }
public void SendAffiliateRejectionEmail(Affiliate affiliate) { _emailProvider.SendAffiliateRejection(affiliate.EmailAddress, affiliate.RejectReason); }
private static DataTable FetchResultsDataTable(Affiliate[] affiliates) { DataTable dtResults = new DataTable("SearchResults"); dtResults.Columns.Add("AffiliateID"); dtResults.Columns.Add("Username"); dtResults.Columns.Add("Name"); dtResults.Columns.Add("SiteURL"); dtResults.Columns.Add("Balance"); dtResults.Columns.Add("RequestPayment"); dtResults.Columns.Add("Commission"); if (affiliates != null && affiliates.Length > 0) foreach (Affiliate affiliate in affiliates) { string commission = ""; if (affiliate.FixedAmount != null) { commission = affiliate.FixedAmount.Value.ToString("C"); } if (affiliate.Percentage != null) { commission += " " + affiliate.Percentage + "%"; } dtResults.Rows.Add(new object[] { affiliate.ID, affiliate.Username, Parsers.ProcessAffiliateName(affiliate.Name), affiliate.SiteURL, affiliate.Balance.ToString("C"), affiliate.RequestPayment, commission }); } return dtResults; }
protected void PrepareAffiliateModel(AffiliateModel model, Affiliate affiliate, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (affiliate != null) { model.Id = affiliate.Id; model.Url = _webHelper.ModifyQueryString(_webHelper.GetStoreLocation(false), "affiliateid=" + affiliate.Id, null); if (!excludeProperties) { model.Active = affiliate.Active; model.Address = affiliate.Address.ToModel(_addressService); } } model.Address.FirstNameEnabled = true; model.Address.FirstNameRequired = true; model.Address.LastNameEnabled = true; model.Address.LastNameRequired = true; model.Address.EmailEnabled = true; model.Address.EmailRequired = true; model.Address.CompanyEnabled = true; model.Address.CountryEnabled = true; model.Address.StateProvinceEnabled = true; model.Address.CityEnabled = true; model.Address.CityRequired = true; model.Address.StreetAddressEnabled = true; model.Address.StreetAddressRequired = true; model.Address.StreetAddress2Enabled = true; model.Address.ZipPostalCodeEnabled = true; model.Address.ZipPostalCodeRequired = true; model.Address.PhoneEnabled = true; model.Address.PhoneRequired = true; model.Address.FaxEnabled = true; model.GridPageSize = _adminAreaSettings.GridPageSize; model.UsernamesEnabled = _customerSettings.UsernamesEnabled; //address //model.Address.AvailableCountries.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Address.SelectCountry"), Value = "0" }); foreach (var c in _countryService.GetAllCountries(true)) { model.Address.AvailableCountries.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString(), Selected = (affiliate != null && c.Id == affiliate.Address.CountryId) }); } var states = model.Address.CountryId.HasValue ? _stateProvinceService.GetStateProvincesByCountryId(model.Address.CountryId.Value, true).ToList() : new List <StateProvince>(); if (states.Count > 0) { foreach (var s in states) { model.Address.AvailableStates.Add(new SelectListItem() { Text = s.Name, Value = s.Id.ToString(), Selected = (affiliate != null && s.Id == affiliate.Address.StateProvinceId) }); } } else { model.Address.AvailableStates.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Address.OtherNonUS"), Value = "0" }); } }
private void InitializePageContent() { AppConfigAffiliateProgramName.Text = AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting) + " Member Sign-Out"; imgLogOut.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/logout.gif"); imgLogOut.AlternateText = AppLogic.GetString("image.altText.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); AskAQuestion.NavigateUrl = "mailto:" + AppLogic.AppConfig("AffiliateEMailAddress"); affiliateheader_small_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/affiliateheader_small.jpg"); AppConfig_AffiliateProgramName2.Text = String.Format(AppLogic.GetString("lataccount.aspx.31", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting)); AppConfig_AffiliateProgramName3.Text = String.Format(AppLogic.GetString("lataccount.aspx.32", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting)); AppConfig_AffiliateProgramName4.Text = String.Format(AppLogic.GetString("lataccount.aspx.30", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting)); tblAccount.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor")); tblAcctInfoBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle")); accountinfo_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/accountinfo.gif"); tblOnlineInfo.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor")); tblOnlineInfoBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle")); onlineinfo_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/onlineinfo.gif"); Affiliate a = new Affiliate(AffiliateID); if (a.AffiliateID != -1) { //Fill Account data fields FirstName.Text = a.FirstName; LastName.Text = a.LastName; EMail.Text = a.EMail.ToLowerInvariant().Trim(); AppConfig_AffiliateProgramName2.Text = String.Format(AppLogic.GetString("lataccount.aspx.31", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("AppConfig.AffiliateProgramName", SkinID, ThisCustomer.LocaleSetting)); AffPassword.Text = String.Empty; AffPassword2.Text = String.Empty; Company.Text = Server.HtmlEncode(a.Company); Address1.Text = Server.HtmlEncode(a.Address1); Address2.Text = Server.HtmlEncode(a.Address2); Suite.Text = Server.HtmlEncode(a.Suite); City.Text = Server.HtmlEncode(a.City); AffState = a.State; using (SqlConnection conn = DB.dbConn()) { conn.Open(); using (IDataReader dr = DB.GetRS("select * from State with (NOLOCK) order by DisplayOrder,Name", conn)) { State.DataSource = dr; State.DataTextField = "Name"; State.DataValueField = "Abbreviation"; State.DataBind(); } } Zip.Text = Server.HtmlEncode(a.Zip); AffCountry = a.Country; using (SqlConnection conn = DB.dbConn()) { conn.Open(); using (IDataReader dr2 = DB.GetRS("select * from Country with (NOLOCK) where Published = 1 order by DisplayOrder,Name", conn)) { Country.DataSource = dr2; Country.DataTextField = "Name"; Country.DataValueField = "Name"; Country.DataBind(); } } Phone.Text = Server.HtmlEncode(a.Phone); DOBTxt.Text = Localization.ToThreadCultureShortDateString(a.DateOfBirth); //Website Data WebSiteName.Text = a.WebSiteName; WebSiteDescription.Text = a.WebSiteDescription; URL.Text = a.URL; } AppLogic.GetButtonDisable(btnUpdate1); AppLogic.GetButtonDisable(btnUpdate2); }
private bool Save() { Affiliate aff = null; var prevApprovementStatus = false; if (AffiliateId.HasValue) { aff = HccApp.ContactServices.Affiliates.Find(AffiliateId.Value); prevApprovementStatus = aff.Approved; } else { aff = new Affiliate { Username = txtUsername.Text.Trim(), Password = txtPassword.Text }; } aff.Email = txtEmail.Text; aff.Enabled = chkEnabled.Checked; if (chkApproved.Checked) { aff.Approved = true; } aff.AffiliateId = txtAffiliateID.Text.Trim(); aff.ReferralAffiliateId = txtReferralId.Text.Trim(); var typeSelection = int.Parse(lstCommissionType.SelectedValue); aff.CommissionType = (AffiliateCommissionType)typeSelection; aff.CommissionAmount = decimal.Parse(CommissionAmountField.Text, NumberStyles.Currency); aff.ReferralDays = int.Parse(txtReferralDays.Text); aff.TaxId = TaxIdField.Text.Trim(); aff.DriversLicenseNumber = DriversLicenseField.Text.Trim(); aff.WebSiteUrl = WebsiteUrlField.Text.Trim(); aff.Address = ucAddress.GetAsAddress(); aff.Notes = NotesTextBox.Text; var userStatus = CreateUserStatus.None; var status = AffiliateRepository.UpdateStatus.UnknownError; if (AffiliateId.HasValue) { status = HccApp.ContactServices.Affiliates.Update(aff); } else { status = HccApp.ContactServices.Affiliates.Create(aff, ref userStatus); } switch (status) { case AffiliateRepository.UpdateStatus.Success: if (!prevApprovementStatus && aff.Approved) { var ui = DnnUserController.Instance.GetUser(DnnGlobal.Instance.GetPortalId(), aff.UserId); var culture = ui.Profile["UsedCulture"] as string; if (string.IsNullOrEmpty(culture)) { culture = "en-US"; } HccApp.ContactServices.AffiliateWasApproved(aff, culture); } if (!string.IsNullOrEmpty(txtReferralId.Text)) { var refaff = HccApp.ContactServices.Affiliates.FindByAffiliateId(txtReferralId.Text.Trim()); if (refaff == null) { ShowMessage(Localization.GetString("UnknownReferralAffiliateID"), ErrorTypes.Warning); return(false); } } break; case AffiliateRepository.UpdateStatus.DuplicateAffiliateID: ShowMessage(Localization.GetString("DuplicateAffiliateID"), ErrorTypes.Error); break; case AffiliateRepository.UpdateStatus.UserCreateFailed: HandleUserCreateFailedStatus(userStatus); break; default: ShowMessage(string.Format(Localization.GetString("AffiliateCreateError"), userStatus), ErrorTypes.Error); break; } return(status == AffiliateRepository.UpdateStatus.Success); }
/// <summary> /// Prepare affiliate model /// </summary> /// <param name="model">Affiliate model</param> /// <param name="affiliate">Affiliate</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the affiliate model /// </returns> public virtual async Task <AffiliateModel> PrepareAffiliateModelAsync(AffiliateModel model, Affiliate affiliate, bool excludeProperties = false) { //fill in model values from the entity if (affiliate != null) { model ??= affiliate.ToModel <AffiliateModel>(); model.Url = await _affiliateService.GenerateUrlAsync(affiliate); //prepare nested search models await PrepareAffiliatedOrderSearchModelAsync(model.AffiliatedOrderSearchModel, affiliate); PrepareAffiliatedCustomerSearchModel(model.AffiliatedCustomerSearchModel, affiliate); //whether to fill in some of properties if (!excludeProperties) { model.AdminComment = affiliate.AdminComment; model.FriendlyUrlName = affiliate.FriendlyUrlName; model.Active = affiliate.Active; } } //prepare address model var address = await _addressService.GetAddressByIdAsync(affiliate?.AddressId ?? 0); if (!excludeProperties && address != null) { model.Address = address.ToModel(model.Address); } await _addressModelFactory.PrepareAddressModelAsync(model.Address, address); model.Address.FirstNameRequired = true; model.Address.LastNameRequired = true; model.Address.EmailRequired = true; model.Address.CountryRequired = true; model.Address.CountyRequired = true; model.Address.CityRequired = true; model.Address.StreetAddressRequired = true; model.Address.ZipPostalCodeRequired = true; model.Address.PhoneRequired = true; return(model); }
/// <summary> /// Prepare paged affiliated order list model /// </summary> /// <param name="searchModel">Affiliated order search model</param> /// <param name="affiliate">Affiliate</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the affiliated order list model /// </returns> public virtual async Task <AffiliatedOrderListModel> PrepareAffiliatedOrderListModelAsync(AffiliatedOrderSearchModel searchModel, Affiliate affiliate) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (affiliate == null) { throw new ArgumentNullException(nameof(affiliate)); } //get parameters to filter orders var startDateValue = !searchModel.StartDate.HasValue ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.StartDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()); var endDateValue = !searchModel.EndDate.HasValue ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.EndDate.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1); var orderStatusIds = searchModel.OrderStatusId > 0 ? new List <int> { searchModel.OrderStatusId } : null; var paymentStatusIds = searchModel.PaymentStatusId > 0 ? new List <int> { searchModel.PaymentStatusId } : null; var shippingStatusIds = searchModel.ShippingStatusId > 0 ? new List <int> { searchModel.ShippingStatusId } : null; //get orders var orders = await _orderService.SearchOrdersAsync(createdFromUtc : startDateValue, createdToUtc : endDateValue, osIds : orderStatusIds, psIds : paymentStatusIds, ssIds : shippingStatusIds, affiliateId : affiliate.Id, pageIndex : searchModel.Page - 1, pageSize : searchModel.PageSize); //prepare list model var model = await new AffiliatedOrderListModel().PrepareToGridAsync(searchModel, orders, () => { //fill in model values from the entity return(orders.SelectAwait(async order => { var affiliatedOrderModel = order.ToModel <AffiliatedOrderModel>(); //fill in additional values (not existing in the entity) affiliatedOrderModel.OrderStatus = await _localizationService.GetLocalizedEnumAsync(order.OrderStatus); affiliatedOrderModel.PaymentStatus = await _localizationService.GetLocalizedEnumAsync(order.PaymentStatus); affiliatedOrderModel.ShippingStatus = await _localizationService.GetLocalizedEnumAsync(order.ShippingStatus); affiliatedOrderModel.OrderTotal = await _priceFormatter.FormatPriceAsync(order.OrderTotal, true, false); affiliatedOrderModel.CreatedOn = await _dateTimeHelper.ConvertToUserTimeAsync(order.CreatedOnUtc, DateTimeKind.Utc); return affiliatedOrderModel; })); }); return(model); }
protected void btnRegister_Click(object sender, EventArgs e) { #region Validate username if (txtUsername.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please specify username!"), Misc.MessageType.Error); return; } if (Affiliate.IsUsernameTaken(txtUsername.Text)) { MessageBox.Show(Lang.Trans("Username is already taken!"), Misc.MessageType.Error); return; } foreach (string reservedUsername in Config.Users.ReservedUsernames) { if (reservedUsername == txtUsername.Text.ToLower()) { MessageBox.Show(Lang.Trans("Username is reserved!"), Misc.MessageType.Error); return; } } try { Affiliate.ValidateUsername(txtUsername.Text); } catch (ArgumentException ex) { MessageBox.Show(ex.Message, Misc.MessageType.Error); return; } #endregion #region Validate passwords if (txtPassword.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please specify password!"), Misc.MessageType.Error); return; } if (txtPasswordConfirm.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please verify password!"), Misc.MessageType.Error); return; } if (txtPassword.Text != txtPasswordConfirm.Text) { MessageBox.Show(Lang.Trans("Passwords do not match!"), Misc.MessageType.Error); return; } try { Affiliate.ValidatePassword(txtPassword.Text); } catch (ArgumentException ex) { MessageBox.Show(ex.Message, Misc.MessageType.Error); return; } #endregion #region Validate name if (txtName.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please enter your name!"), Misc.MessageType.Error); return; } #endregion #region Validate e-mail address try { if (txtEmail.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please specify e-mail address!"), Misc.MessageType.Error); return; } } catch (ArgumentException err) // Invalid e-mail address { MessageBox.Show(err.Message, Misc.MessageType.Error); return; } #endregion #region Validate site URL if (txtSiteUrl.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please enter your site URL!"), Misc.MessageType.Error); return; } #endregion #region Validate payment details if (txtPaymentDetails.Text.Trim().Length == 0) { MessageBox.Show(Lang.Trans("Please enter your payment details!"), Misc.MessageType.Error); return; } #endregion Affiliate affiliate = new Affiliate(txtUsername.Text.Trim()); affiliate.Password = txtPassword.Text; affiliate.Name = txtName.Text.Trim(); affiliate.Email = txtEmail.Text.Trim(); affiliate.SiteURL = txtSiteUrl.Text.Trim(); affiliate.PaymentDetails = txtPaymentDetails.Text.Trim(); affiliate.Save(); AffiliateSession affiliateSession = null; try { affiliateSession = new AffiliateSession(txtUsername.Text.Trim()); affiliateSession.Authorize(txtPassword.Text.Trim()); } catch (NotFoundException err) { MessageBox.Show(err.Message, Misc.MessageType.Error); return; } catch (AccessDeniedException err) { MessageBox.Show(err.Message, Misc.MessageType.Error); return; } catch (Exception err) { IPLogger.Log(txtUsername.Text, Request.UserHostAddress, IPLogger.ActionType.AffiliateLoginFailed); MessageBox.Show(err.Message, Misc.MessageType.Error); return; } CurrentAffiliateSession = affiliateSession; Response.Redirect("~/Affiliates/Home.aspx"); }
public Summary(Affiliate affiliate, int customerId) : base(affiliate, customerId) { InvoiceItems = new InvoiceItems(); DeliveryTypes = new List <DeliveryType>(); PaymentTypes = new List <PaymentType>(); }