//public static Collection<Affiliate> FindByUserId(string bvin) //{ // return Mapper.FindByUserId(bvin); //} //public static Collection<Affiliate> FindEnabledByUserId(string bvin) //{ // Collection<Affiliate> enabledAffiliates = new Collection<Affiliate>(); // foreach (Contacts.Affiliate item in Mapper.FindByUserId(bvin)) { // if (item.Enabled) { // enabledAffiliates.Add(item); // } // } // return enabledAffiliates; //} //DTO public AffiliateDTO ToDto() { AffiliateDTO dto = new AffiliateDTO(); dto.Id = this.Id; dto.StoreId = this.StoreId; dto.Enabled = this.Enabled; dto.ReferralId = this.ReferralId; dto.DisplayName = this.DisplayName; dto.Address = this.Address.ToDto(); dto.CommissionAmount = this.CommissionAmount; dto.CommissionType = (AffiliateCommissionTypeDTO)((int)this.CommissionType); dto.ReferralDays = this.ReferralDays; dto.TaxId = this.TaxId; dto.DriversLicenseNumber = this.DriversLicenseNumber; dto.WebSiteUrl = this.WebSiteUrl; dto.CustomThemeName = this.CustomThemeName; dto.Notes = this.Notes; dto.LastUpdatedUtc = this.LastUpdatedUtc; foreach (AffiliateContact contact in this.Contacts) { dto.Contacts.Add(contact.ToDto()); } return dto; }
private AffiliateDTO OldToNewAffiliate(data.bvc_Affiliate aff) { AffiliateDTO affiliate = new AffiliateDTO(); BVC2004Address oldAddress = new BVC2004Address(); oldAddress.FromXmlString(aff.Address); affiliate.Address = new AddressDTO(); if (oldAddress != null) { oldAddress.CopyTo(affiliate.Address, EFConnString(settings.SourceConnectionString())); } affiliate.CommissionAmount = (decimal)aff.CommissionAmount; switch (aff.CommissionType) { case 0: affiliate.CommissionType = AffiliateCommissionTypeDTO.None; break; case 1: affiliate.CommissionType = AffiliateCommissionTypeDTO.PercentageCommission; break; case 2: affiliate.CommissionType = AffiliateCommissionTypeDTO.FlatRateCommission; break; default: affiliate.CommissionType = AffiliateCommissionTypeDTO.PercentageCommission; break; } affiliate.CustomThemeName = aff.StyleSheet; affiliate.DisplayName = aff.DisplayName; affiliate.DriversLicenseNumber = aff.DriversLicenseNumber; affiliate.Enabled = true; affiliate.Id = -1; affiliate.LastUpdatedUtc = DateTime.UtcNow; affiliate.Notes = string.Empty; affiliate.ReferralDays = aff.ReferralDays; affiliate.ReferralId = aff.ID.ToString(); affiliate.TaxId = aff.TaxID; affiliate.WebSiteUrl = aff.WebSiteURL; affiliate.Contacts = new List<AffiliateContactDTO>(); return affiliate; }
public void FromDto(AffiliateDTO dto) { if (dto == null) return; this.Id = dto.Id; this.StoreId = dto.StoreId; this.Enabled = dto.Enabled; this.ReferralId = dto.ReferralId; this.DisplayName = dto.DisplayName; this.Address.FromDto(dto.Address); this.CommissionAmount = dto.CommissionAmount; this.CommissionType = (AffiliateCommissionType)((int)dto.CommissionType); this.ReferralDays = dto.ReferralDays; this.TaxId = dto.TaxId; this.DriversLicenseNumber = dto.DriversLicenseNumber; this.WebSiteUrl = dto.WebSiteUrl; this.CustomThemeName = dto.CustomThemeName; this.Notes = dto.Notes; this.LastUpdatedUtc = dto.LastUpdatedUtc; this.Contacts.Clear(); foreach (AffiliateContactDTO contact in dto.Contacts) { AffiliateContact c = new AffiliateContact(); c.FromDto(contact); this.Contacts.Add(c); } }
public ApiResponse<AffiliateDTO> AffiliatesUpdate(AffiliateDTO item) { ApiResponse<AffiliateDTO> result = new ApiResponse<AffiliateDTO>(); result = RestHelper.PostRequest<ApiResponse<AffiliateDTO>>(this.fullApiUri + "affiliates/" + item.Id + "?key=" + Enc(key), MerchantTribe.Web.Json.ObjectToJson(item)); return result; }