예제 #1
0
        private static Affiliate DBMapping(DBAffiliate dbItem)
        {
            if (dbItem == null)
                return null;

            Affiliate item = new Affiliate();
            item.AffiliateID = dbItem.AffiliateID;
            item.FirstName = dbItem.FirstName;
            item.LastName = dbItem.LastName;
            item.MiddleName = dbItem.MiddleName;
            item.PhoneNumber = dbItem.PhoneNumber;
            item.Email = dbItem.Email;
            item.FaxNumber = dbItem.FaxNumber;
            item.Company = dbItem.Company;
            item.Address1 = dbItem.Address1;
            item.Address2 = dbItem.Address2;
            item.City = dbItem.City;
            item.StateProvince = dbItem.StateProvince;
            item.ZipPostalCode = dbItem.ZipPostalCode;
            item.CountryID = dbItem.CountryID;
            item.Deleted = dbItem.Deleted;
            item.Active = dbItem.Active;
            return item;
        }
예제 #2
0
        public Affiliate SaveInfo()
        {
            Affiliate affiliate = this.AffiliateService.GetAffiliateById(this.AffiliateId);

            if (affiliate != null)
            {
                affiliate.FirstName = txtFirstName.Text;
                affiliate.LastName = txtLastName.Text;
                affiliate.MiddleName = txtMiddleName.Text;
                affiliate.PhoneNumber = txtPhoneNumber.Text;
                affiliate.Email = txtEmail.Text;
                affiliate.FaxNumber = txtFaxNumber.Text;
                affiliate.Company = txtCompany.Text;
                affiliate.Address1 = txtAddress1.Text;
                affiliate.Address2 = txtAddress2.Text;
                affiliate.City = txtCity.Text;
                affiliate.StateProvince = txtStateProvince.Text;
                affiliate.ZipPostalCode =  txtZipPostalCode.Text;
                affiliate.CountryId = int.Parse(this.ddlCountry.SelectedItem.Value);
                affiliate.Active = cbActive.Checked;
                this.AffiliateService.UpdateAffiliate(affiliate);
            }
            else
            {
                affiliate = new Affiliate()
                {
                    FirstName = txtFirstName.Text,
                    LastName = txtLastName.Text,
                    MiddleName = txtMiddleName.Text,
                    PhoneNumber = txtPhoneNumber.Text,
                    Email = txtEmail.Text,
                    FaxNumber = txtFaxNumber.Text,
                    Company = txtCompany.Text,
                    Address1 = txtAddress1.Text,
                    Address2 = txtAddress2.Text,
                    City = txtCity.Text,
                    StateProvince = txtStateProvince.Text,
                    ZipPostalCode = txtZipPostalCode.Text,
                    CountryId = int.Parse(this.ddlCountry.SelectedItem.Value),
                    Active = cbActive.Checked
                };
                this.AffiliateService.InsertAffiliate(affiliate);
            }

            return affiliate;
        }
예제 #3
0
        /// <summary>
        /// Updates the affiliate
        /// </summary>
        /// <param name="affiliate">Affiliate</param>
        public void UpdateAffiliate(Affiliate affiliate)
        {
            if (affiliate == null)
                throw new ArgumentNullException("affiliate");

            affiliate.FirstName = CommonHelper.EnsureNotNull(affiliate.FirstName);
            affiliate.LastName = CommonHelper.EnsureNotNull(affiliate.LastName);
            affiliate.FirstName = CommonHelper.EnsureMaximumLength(affiliate.FirstName, 100);
            affiliate.LastName = CommonHelper.EnsureMaximumLength(affiliate.LastName, 100);
            affiliate.MiddleName = CommonHelper.EnsureNotNull(affiliate.MiddleName);
            affiliate.MiddleName = CommonHelper.EnsureMaximumLength(affiliate.MiddleName, 100);
            affiliate.PhoneNumber = CommonHelper.EnsureNotNull(affiliate.PhoneNumber);
            affiliate.PhoneNumber = CommonHelper.EnsureMaximumLength(affiliate.PhoneNumber, 50);
            affiliate.Email = CommonHelper.EnsureNotNull(affiliate.Email);
            affiliate.Email = CommonHelper.EnsureMaximumLength(affiliate.Email, 255);
            affiliate.FaxNumber = CommonHelper.EnsureNotNull(affiliate.FaxNumber);
            affiliate.FaxNumber = CommonHelper.EnsureMaximumLength(affiliate.FaxNumber, 50);
            affiliate.Company = CommonHelper.EnsureNotNull(affiliate.Company);
            affiliate.Company = CommonHelper.EnsureMaximumLength(affiliate.Company, 100);
            affiliate.Address1 = CommonHelper.EnsureNotNull(affiliate.Address1);
            affiliate.Address1 = CommonHelper.EnsureMaximumLength(affiliate.Address1, 100);
            affiliate.Address2 = CommonHelper.EnsureNotNull(affiliate.Address2);
            affiliate.Address2 = CommonHelper.EnsureMaximumLength(affiliate.Address2, 100);
            affiliate.City = CommonHelper.EnsureNotNull(affiliate.City);
            affiliate.City = CommonHelper.EnsureMaximumLength(affiliate.City, 100);
            affiliate.StateProvince = CommonHelper.EnsureNotNull(affiliate.StateProvince);
            affiliate.StateProvince = CommonHelper.EnsureMaximumLength(affiliate.StateProvince, 100);
            affiliate.ZipPostalCode = CommonHelper.EnsureNotNull(affiliate.ZipPostalCode);
            affiliate.ZipPostalCode = CommonHelper.EnsureMaximumLength(affiliate.ZipPostalCode, 30);

            if (!_context.IsAttached(affiliate))
                _context.Affiliates.Attach(affiliate);

            _context.SaveChanges();
        }