コード例 #1
0
        public void RemoveContact(Contact entity, Int32 customerId, Int32 companyId)
        {
            var ccManager = new CustomerContactManager(this);
            var cc = new CustomerContact();
            cc.ContactId = entity.ContactId;
            cc.CustomerId = customerId;
            ccManager.Delete(cc);

            var contactManager = new ContactManager(this);
            contactManager.Delete(entity);
        }
コード例 #2
0
        public ProductListViewModel(ProductBase content, 
            IMarket currentMarket,
            CustomerContact currentContact)
            : this()
        {
            ImageUrl = content.GetDefaultImage();
            IsVariation = false;
            AllImageUrls = content.AssetUrls();

            PopulateCommonData(content, currentMarket, currentContact);
        }
コード例 #3
0
        private void SaveContact()
        {
            contactManager = new ContactManager(this);
            contact = new DataClasses.Contact();
            var originalContact = new DataClasses.Contact();

            if (!String.IsNullOrEmpty(Request["ContactId"]))
            {
                originalContact = contactManager.GetContact(Convert.ToInt32(Request["ContactId"]));
                contact.CopyPropertiesFrom(originalContact);
            }
            else contact.UserId = User.Identity.UserId;

            contact.CompanyId = Company.CompanyId;
            contact.AddressComp = ucAddress.AddressComp;
            contact.AddressNumber = ucAddress.AddressNumber;
            contact.PostalCode = ucAddress.PostalCode;

            contact.CellPhone = txtCellPhone.Text;
            contact.Email = txtMail.Text;
            contact.Msn = txtMsn.Text;
            contact.Name = txtName.Text;
            contact.Observation = txtObservation.Text;
            contact.Phone = txtPhone.Text;
            contact.Phone2 = txtPhone2.Text;
            contact.Sector = txtSector.Text;
            contact.Skype = txtSkype.Text;


            if (!String.IsNullOrEmpty(Request["ContactId"]))
                contactManager.Update(originalContact, contact);
            else
            {
                contactManager.Insert(contact);

                if (Session["CustomerId"] != null)
                {
                    var customerContact = new CustomerContact();
                    customerContact.CompanyId = Company.CompanyId;
                    customerContact.CustomerId = Convert.ToInt32(Session["CustomerId"].ToString());
                    customerContact.ContactId = contact.ContactId;
                    contactManager.InsertCustomerContact(customerContact);
                }
                else
                {
                    var supplierContact = new SupplierContact();
                    supplierContact.CompanyId = Company.CompanyId;
                    supplierContact.SupplierId = Convert.ToInt32(Session["SupplierId"].ToString());
                    supplierContact.ContactId = contact.ContactId;
                    contactManager.InsertSupplierContact(supplierContact);
                }
            }
        }
コード例 #4
0
        public void AddContact(Contact entity, Int32 companyId, Int32 customerId)
        {
            var contactManager = new ContactManager(this);
            entity.CompanyId = companyId;
            contactManager.Insert(entity);

            var ccManager = new CustomerContactManager(this);
            var cc = new CustomerContact();
            cc.CustomerId = customerId;
            cc.ContactId = entity.ContactId;
            cc.CompanyId = companyId;
            ccManager.Insert(cc);
        }
コード例 #5
0
        protected void SetContactProperties(CustomerContact contact)
        {
            Organization org = Organization.CreateInstance();

            org.Name = "ParentOrg";
            org.SaveChanges();

            // Remember the EffectiveCustomerGroup!
            contact.CustomerGroup = "MyBuddies";

            // The custom field
            contact["Geography"] = "West";
            contact.OwnerId      = org.PrimaryKeyId;

            contact.SaveChanges();
        }
コード例 #6
0
        /// <summary>
        /// Adds a payment, shipping address, billing address and finally saves the order as a purchase order.
        /// </summary>
        /// <param name="contact">The order customer.</param>
        /// <param name="cart">The cart to be processed and saved.</param>
        private void ProcessAndSaveAsPurchaseOrder(CustomerContact contact, ICart cart)
        {
            var dto            = ShippingManager.GetShippingMethodsByMarket(cart.MarketId.Value, false);
            var contactAddress = contact.ContactAddresses.First();
            var orderAddress   = CreateOrderAddress(cart, contactAddress);

            cart.GetFirstShipment().ShippingAddress  = orderAddress;
            cart.GetFirstShipment().ShippingMethodId = dto.ShippingMethod[0].ShippingMethodId;
            var payment = CreatePayment(contact, cart);

            cart.AddPayment(payment);
            payment.BillingAddress = orderAddress;
            payment.Status         = PaymentStatus.Processed.ToString();

            _orderRepository.SaveAsPurchaseOrder(cart);
        }
        public IActionResult GetCustomerContact([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(HttpBadRequest(ModelState));
            }

            CustomerContact customerContact = _context.CustomerContact.Single(m => m.CustomerContactId == id);

            if (customerContact == null)
            {
                return(HttpNotFound());
            }

            return(Ok(customerContact));
        }
コード例 #8
0
        /// <summary>
        /// Inits the marketing context.
        /// </summary>
        private void InitMarketingContext()
        {
            OrderGroup group = this.OrderGroup;

            SetContext(MarketingContext.ContextConstants.ShoppingCart, group);

            // Set customer segment context
            MembershipUser user = SecurityContext.Current.CurrentUser;

            if (user != null)
            {
                CustomerProfileWrapper profile = SecurityContext.Current.CurrentUserProfile as CustomerProfileWrapper;

                if (profile != null)
                {
                    SetContext(MarketingContext.ContextConstants.CustomerProfile, profile);

                    CustomerContact customerContact = CustomerContext.Current.GetContactForUser(user);
                    if ((Guid)customerContact.PrimaryKeyId != group.CustomerId)
                    {
                        customerContact = CustomerContext.Current.GetContactById(group.CustomerId);
                    }
                    if (customerContact != null)
                    {
                        SetContext(MarketingContext.ContextConstants.CustomerContact, customerContact);

                        Guid accountId      = (Guid)customerContact.PrimaryKeyId;
                        Guid organizationId = Guid.Empty;
                        if (customerContact.ContactOrganization != null)
                        {
                            organizationId = (Guid)customerContact.ContactOrganization.PrimaryKeyId;
                        }

                        SetContext(MarketingContext.ContextConstants.CustomerSegments, MarketingContext.Current.GetCustomerSegments(accountId, organizationId));
                    }
                }
            }

            // Set customer promotion history context
            SetContext(MarketingContext.ContextConstants.CustomerId, this.OrderGroup.CustomerId);

            // Now load current order usage dto, which will help us determine the usage limits
            // Load existing usage Dto for the current order
            PromotionUsageDto usageDto = PromotionManager.GetPromotionUsageDto(0, Guid.Empty, group.OrderGroupId);

            SetContext(MarketingContext.ContextConstants.PromotionUsage, usageDto);
        }
コード例 #9
0
        // ToDo: Exercises in customers module
        public ActionResult CreateAccount(AccountPage currentPage, string userName, string passWord)
        {
            // The important here are the Roles and the Contact properties
            string firstName    = userName;
            string lastName     = userName;
            string emailAddress = firstName + "." + lastName + "@epi.com"; //
            string password     = passWord;

            //CustomerContext.Current.CurrentContact.

            MembershipUser membershipGuy = null;

            MembershipCreateStatus createStatus;

            membershipGuy = Membership.CreateUser(emailAddress, password, emailAddress,
                                                  null, null, true, out createStatus);
            //CustomerContext.Current.
            // Create the Contact in ECF
            CustomerContact customerContact = CustomerContact.CreateInstance(membershipGuy);

            customerContact.FirstName          = firstName;
            customerContact.LastName           = lastName;
            customerContact.RegistrationSource = String.Format("{0}, {1}"
                                                               , this.Request.Url.Host, SiteContext.Current);

            //customerContact["Email"] = emailAddress; // can do...
            customerContact.Email = emailAddress;

            // Do the "SaveChanges()" before setting ECF-"Roles"
            customerContact.SaveChanges();

            // These Roles are ECF specific ... Used by CM ... and obsolete in 9
            //SecurityContext.Current.AssignUserToGlobalRole(membershipGuy, AppRoles.EveryoneRole);
            //SecurityContext.Current.AssignUserToGlobalRole(membershipGuy, AppRoles.RegisteredRole);

            // We don't need this anymore for visitors/customers
            Roles.AddUserToRole(membershipGuy.UserName, AppRoles.EveryoneRole);
            Roles.AddUserToRole(membershipGuy.UserName, AppRoles.RegisteredRole); // could mean "ClubMember"
            // Could have other use of it...
            Roles.AddUserToRole(membershipGuy.UserName, "ClubMember");

            // Call for further properties to be set
            SetContactProperties(customerContact);

            //CustomerContext.Current.CurrentContact.e
            return(null); // for now
        }
コード例 #10
0
        private CustomerContact ApplyChanges(CustomerContactModel model)
        {
            var _obj = new CustomerContact();

            _obj.CustomerContactID = model.CustomerContactID;
            _obj.CustomerID        = model.CustomerID;
            _obj.ContactID         = SaveContact(model);
            _obj.SortOrder         = model.SortOrder; /////////////--- ??? --- !!!
            _obj.CreatedDate       = !string.IsNullOrEmpty(model.CreatedDate)
                ? DateTime.Parse(model.CreatedDate)
                : DateTime.Now;
            _obj.CreatedBy   = _principal.Id;
            _obj.UpdatedDate = DateTime.Now;
            _obj.UpdatedBy   = _principal.Id;
            _obj.IsActive    = true;
            return(_obj);
        }
コード例 #11
0
ファイル: LoginController.cs プロジェクト: ajuris/Quicksilver
        protected virtual void SendMarketingEmailConfirmationMail(string userId, CustomerContact contact, string token)
        {
            var optinConfirmEmailUrl = Url.Action("ConfirmOptinToken", "Login", new { userId, token }, protocol: Request.Url.Scheme);

            try
            {
                var confirmationMailTitle = _contentLoader.Get <MailBasePage>(StartPage.RegistrationConfirmationMail).MailTitle;
                var confirmationMailBody  = _mailService.GetHtmlBodyForMail(StartPage.RegistrationConfirmationMail, new NameValueCollection(), StartPage.Language.Name);
                confirmationMailBody = confirmationMailBody.Replace("[OptinConfirmEmailUrl]", optinConfirmEmailUrl);
                confirmationMailBody = confirmationMailBody.Replace("[Customer]", contact.LastName ?? contact.Email);
                _mailService.Send(confirmationMailTitle, confirmationMailBody, contact.Email);
            }
            catch (Exception e)
            {
                _logger.Warning($"Unable to send marketing email confirmation to '{contact.Email}'.", e);
            }
        }
コード例 #12
0
        /// <summary>
        /// Gets the name of the user.
        /// </summary>
        /// <param name="userGuid">The user GUID.</param>
        /// <returns></returns>
        public static string GetUserName(Guid userGuid)
        {
            string          retVal          = userGuid.ToString();
            MembershipUser  user            = Membership.GetUser(userGuid);
            CustomerContact customerContact = null;

            if (user != null)
            {
                retVal          = user.UserName;
                customerContact = CustomerContext.Current.GetContactForUser(user);
            }
            if (customerContact != null)
            {
                retVal = customerContact.FullName;
            }
            return(retVal);
        }
コード例 #13
0
ファイル: UserService.cs プロジェクト: Geta/PayPal
        public virtual CustomerContact GetCustomerContact(string email)
        {
            if (email == null)
            {
                throw new ArgumentNullException("email");
            }

            CustomerContact contact = null;
            SiteUser        user    = GetUser(email);

            if (user != null)
            {
                contact = _customerContext.GetContactById(new Guid(user.Id));
            }

            return(contact);
        }
コード例 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Insert
     if (DataItem is GridInsertionObject)
     {
         contact           = new CustomerContact();
         btnInsert.Visible = true;
     }
     //Update
     else if (DataItem != null && DataItem.GetType() == typeof(CustomerContact))
     {
         //Cast the DataItem as a Customer Contact and store it in contact
         contact                     = (CustomerContact)DataItem;
         btnUpdate.Visible           = true;
         rcbSalutation.SelectedValue = contact.Salutation;
     }
 }
コード例 #15
0
        public static Contact ConvertToContact(this CustomerContact customerContact)
        {
            if (customerContact == null)
            {
                return(null);
            }

            return(new Contact
            {
                PrimaryKeyId = customerContact.PrimaryKeyId,
                Addresses = customerContact.ContactAddresses.Select(a => a.ConvertToAddress()).ToArray(),
                FirstName = customerContact.FirstName,
                LastName = customerContact.LastName,
                Email = customerContact.Email,
                RegistrationSource = customerContact.RegistrationSource
            });
        }
コード例 #16
0
        public IEnumerable <IPriceValue> FakePromotion(EntryContentBase sku) // support case
        {
            //List<IPriceValue> priceList = new List<IPriceValue>();
            IMarket market = _marketService.GetCurrentMarket();

            // ...first add the default for all customer pricing
            List <CustomerPricing> customerPricing = new List <CustomerPricing>
            {
                new CustomerPricing(CustomerPricing.PriceType.AllCustomers, string.Empty)
            };

            // ...then add the price type specific to a user and to a possible price group
            IPrincipal currentUser = PrincipalInfo.CurrentPrincipal;

            if (CustomerContext.Current.CurrentContact != null)
            {
                if (!string.IsNullOrEmpty(currentUser.Identity.Name))
                {
                    customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, currentUser.Identity.Name));
                }

                CustomerContact currentUserContact = CustomerContext.Current.CurrentContact;

                if (currentUserContact != null && !string.IsNullOrEmpty(currentUserContact.EffectiveCustomerGroup))
                { // Could look for both Org & Cust.
                    customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup,
                                                            currentUserContact.EffectiveCustomerGroup));
                }
            }

            // Add the BasePrice (in this case the "PromotionPrice")
            customerPricing.Add(new CustomerPricing((CustomerPricing.PriceType) 3, string.Empty));

            PriceFilter filter = new PriceFilter()
            {
                Quantity              = 1M,
                Currencies            = new Currency[] { "USD" },
                CustomerPricing       = customerPricing,
                ReturnCustomerPricing = true // note this arg.
            };

            CatalogKey catalogKey = new CatalogKey(sku.Code);

            return(_priceService.GetPrices(
                       market.MarketId.Value, DateTime.Now, catalogKey, filter).ToList());
        }
コード例 #17
0
        public Customer Insert(Customer customer)
        {
            var contact = CustomerContact.CreateInstance();

            contact.FirstName    = customer.FirstName;
            contact.LastName     = customer.LastName;
            contact.FullName     = $"{customer.FirstName} {customer.LastName}";
            contact.Email        = customer.Email;
            contact.PrimaryKeyId = new PrimaryKeyId(Guid.NewGuid());
            contact.UserId       = customer.UserId;
            var result = contact.SaveChanges();

            return(new Customer()
            {
                Email = result.Email, FirstName = result.FirstName, LastName = result.LastName
            });
        }
コード例 #18
0
        public ActionResult Login(LoginPage currentPage, LoginViewModel model, LoginForm loginForm, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            string          user = loginForm.Username;
            string          pw   = loginForm.Password;
            CustomerContact cc   = null;

            if (Membership.ValidateUser(user, pw))
            {
                MembershipUser account = Membership.GetUser(user);
                if (account != null)
                {
                    var profile = SecurityContext.Current.CurrentUserProfile as CustomerProfileWrapper;
                    if (profile != null)
                    {
                        cc = CustomerContext.Current.GetContactForUser(account);
                        CreateAuthenticationCookie(ControllerContext.HttpContext, user, Mediachase.Commerce.Core.AppContext.Current.ApplicationName, false);

                        string url = returnUrl;

                        if (string.IsNullOrEmpty(returnUrl))
                        {
                            if (currentPage.LoggedInPage != null)
                            {
                                url = _urlResolver.GetUrl(currentPage.LoggedInPage);
                            }
                            else
                            {
                                url = _urlResolver.GetUrl(ContentReference.StartPage);
                            }
                        }

                        _metrics.Count("Users", "Login Success");
                        return(Redirect(url));
                    }
                }
            }
            ModelState.AddModelError("LoginForm.ValidationMessage", _localizationService.GetString("/common/account/login_error"));
            _metrics.Count("Users", "Login Failure");
            return(View("Index", model));
        }
コード例 #19
0
 protected void LoginButton_Click(object sender, EventArgs e)
 {
     if (Password.Text.Length == 0)
     {
         ErrorMessage.Text = "Enter your password.";
         return;
     }
     try
     {
         using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
         {
             session.BeginUpdate();
             Root velocityDbroot = (Root)session.Open(Root.PlaceInDatabase, 1, 1, false);
             if (velocityDbroot == null)
             {
                 ErrorMessage.Text = "The entered email address is not registered with this website";
                 session.Abort();
                 return;
             }
             CustomerContact lookup = new CustomerContact(Email.Text, null);
             if (!velocityDbroot.customersByEmail.TryGetKey(lookup, ref lookup))
             {
                 ErrorMessage.Text = "The entered email address is not registered with this website";
                 session.Abort();
                 return;
             }
             if (lookup.password != Password.Text)
             {
                 ErrorMessage.Text = "The entered password does not match the registered password";
                 session.Abort();
                 return;
             }
             session.Commit();
             Session["UserName"]  = lookup.UserName;
             Session["Email"]     = Email.Text;
             Session["FirstName"] = lookup.FirstName;
             Session["LastName"]  = lookup.LastName;
             FormsAuthentication.RedirectFromLoginPage(Email.Text, false);
         }
     }
     catch (System.Exception ex)
     {
         ErrorMessage.Text = ex.ToString() + ex.Message;
     }
 }
コード例 #20
0
        private void btnDeleteContact_Click(object sender, EventArgs e)
        {
            CustomerContact _DeleteContact = new CustomerContact();

            _DeleteContact = CustomerDb.GetCustomerContactById(ContactId);
            DialogResult dialogResult = MessageBox.Show(this, "Are you sure you wish to Delete Contact ", "Delete Contact", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (dialogResult == DialogResult.Yes)
            {
                CustomerDb.DeleteContact(_DeleteContact);
                BindContacts(CustomerId);
            }
            else if (dialogResult == DialogResult.No)
            {
                //do something else
            }
            BindContacts(CustomerId);
        }
コード例 #21
0
        public async Task <ActionResult> EditContact(string Email, string CustomerId, string Name, string ContactNumber, string Id)//([Bind(Include = "Id,Email,ContactNumber,Name,CustomerId")] CustomerContact contact)
        {
            CustomerContact contact = new CustomerContact();

            contact.Email         = Email;
            contact.CustomerId    = CustomerId;
            contact.Name          = Name;
            contact.ContactNumber = ContactNumber;
            contact.Id            = Id;
            if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(CustomerId) && !string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(ContactNumber) && !string.IsNullOrEmpty(Id))
            {
                db.Entry(contact).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Contacts", new { id = contact.CustomerId }));
            }
            return(RedirectToAction("Index"));
        }
コード例 #22
0
        public void FindCustomerContactByLinkAccountTokenShouldReturnFirstContact()
        {
            var expectedContact = new CustomerContact();
            var dataLoader      = A.Fake <IVippsLoginDataLoader>();

            A.CallTo(() => dataLoader.FindContactsByLinkAccountToken(A <Guid> ._))
            .Returns(new[] { expectedContact, new CustomerContact() });
            var service = new VippsLoginCommerceService(
                A.Fake <IVippsLoginService>(),
                A.Fake <IVippsLoginMapper>(),
                dataLoader,
                A.Fake <ICustomerContactService>()
                );

            var contact = service.FindCustomerContactByLinkAccountToken(Guid.Empty);

            Assert.Equal(expectedContact, contact);
        }
コード例 #23
0
        public void FindCustomerContactShouldReturnNotEqualLastContact()
        {
            var expectedContact = new CustomerContact();
            var dataLoader      = A.Fake <IVippsLoginDataLoader>();

            A.CallTo(() => dataLoader.FindContactsBySubjectGuid(A <Guid> ._))
            .Returns(new[] { new CustomerContact(), expectedContact });
            var service = new VippsLoginCommerceService(
                A.Fake <IVippsLoginService>(),
                A.Fake <IVippsLoginMapper>(),
                dataLoader,
                A.Fake <ICustomerContactService>()
                );

            var contact = service.FindCustomerContact(Guid.Empty);

            Assert.NotEqual(expectedContact, contact);
        }
コード例 #24
0
        public ProductListViewModel(ProductContent content,
                                    IMarket currentMarket,
                                    CustomerContact currentContact)
            : this()
        {
            ImageUrl     = content.GetDefaultImage();
            IsVariation  = false;
            AllImageUrls = content.AssetUrls();

            PopulateCommonData(content, currentMarket, currentContact);

            var variation = content.GetFirstVariation();

            if (variation != null)
            {
                PopulatePrices(variation, currentMarket);
            }
        }
コード例 #25
0
        public void AddAddress(string email, Address address)
        {
            var             userId  = Customer.CreateUserId(email);
            CustomerContact contact = _customerContext.GetContactByUserId(userId);

            if (contact == null)
            {
                return;
            }

            var customerContact = address.ToCustomerAddress();

            contact.AddContactAddress(customerContact);
            contact.SaveChanges();
            contact.PreferredShippingAddress = customerContact;
            contact.SaveChanges();
            return;
        }
コード例 #26
0
        private void NewContact_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            CustomerContact cc = (CustomerContact)e.PopupWindowViewCurrentObject;

            e.PopupWindow.View.ObjectSpace.CommitChanges();
            View.ObjectSpace.Refresh();
            MessageOptions options = new MessageOptions();

            options.Message = string.Format("Contact added for :{0}  {1}",
                                            cc.Customers.CustomerName,
                                            cc.FullName);
            options.Type         = InformationType.Success;
            options.Web.Position = InformationPosition.Right;
            options.Win.Caption  = "Success";
            options.Win.Type     = WinMessageType.Alert;
            options.Duration     = 10000;
            Application.ShowViewStrategy.ShowMessage(options);
        }
コード例 #27
0
        public override Money?GetPlacedPrice(
            EntryContentBase entry,
            decimal quantity,
            CustomerContact customerContact,
            MarketId marketId,
            Currency currency)
        {
            var customerPricing = new List <CustomerPricing>
            {
                CustomerPricing.AllCustomers
            };

            if (customerContact != null)
            {
                var userKey = _mapUserKey.ToUserKey(customerContact.UserId);
                if (userKey != null && !string.IsNullOrWhiteSpace(userKey.ToString()))
                {
                    customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, userKey.ToString()));
                }

                if (!string.IsNullOrEmpty(customerContact.EffectiveCustomerGroup))
                {
                    customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup,
                                                            customerContact.EffectiveCustomerGroup));
                }
            }

            var priceFilter = new PriceFilter
            {
                Currencies = new List <Currency> {
                    currency
                },
                Quantity              = quantity,
                CustomerPricing       = customerPricing,
                ReturnCustomerPricing = false
            };

            var priceValue = _priceService
                             .GetPrices(marketId, DateTime.UtcNow, new CatalogKey(entry.Code), priceFilter)
                             .OrderBy(pv => pv.UnitPrice)
                             .FirstOrDefault();

            return(priceValue?.UnitPrice);
        }
コード例 #28
0
        public static void CreateContact(CustomerContact customerContact, Guid userId,
                                         ContactModelExtended contactModel)
        {
            customerContact.PrimaryKeyId = new PrimaryKeyId(userId);
            customerContact.FirstName    = contactModel.FirstName;
            customerContact.LastName     = contactModel.LastName;
            customerContact.Email        = contactModel.Email;
            customerContact.UserId       =
                "String:" + contactModel
                .Email;     // The UserId needs to be set in the format "String:{email}". Else a duplicate CustomerContact will be created later on.
            customerContact.RegistrationSource = contactModel.RegistrationSource;

            if (contactModel.Addresses != null)
            {
                foreach (var address in contactModel.Addresses)
                {
                    customerContact.AddContactAddress(
                        address.ConvertToCustomerAddress(CustomerAddress.CreateInstance()));
                }
            }

            UpdateMetaFields(customerContact, contactModel,
                             new List <string> {
                "FirstName", "LastName", "Email", "RegistrationSource"
            });

            // The contact, or more likely its related addresses, must be saved to the database before we can set the preferred
            // shipping and billing addresses. Using an address id before its saved will throw an exception because its value
            // will still be null.
            customerContact.SaveChanges();

            // Once the contact has been saved we can look for any existing addresses.
            var defaultAddress = customerContact.ContactAddresses.FirstOrDefault();

            if (defaultAddress != null)
            {
                // If an addresses was found, it will be used as default for shipping and billing.
                customerContact.PreferredShippingAddress = defaultAddress;
                customerContact.PreferredBillingAddress  = defaultAddress;

                // Save the address preferences also.
                customerContact.SaveChanges();
            }
        }
コード例 #29
0
        private CustomerContactViewModel GetCustomerContctInfo(int id)
        {
            CustomerContactViewModel    customerContactVm = new CustomerContactViewModel();
            List <ContactType>          contactTypes;
            Dictionary <string, string> ContactStatusList;

            GetContactTypesandStatus(out contactTypes, out ContactStatusList);

            customerContactVm         = new CustomerContactViewModel();
            restProperties.Controller = typeof(CustomerContact).Name;
            restProperties.Method     = "GetContactInformation";
            restProperties.MethodType = Method.GET;

            restProperties.Parameters = new List <CIRestParameter>();
            restProperties.Parameters.Add(new CIRestParameter()
            {
                key   = "id",
                value = id
            });

            IRestResponse <CustomerContact> response = CIRestService.ExecuteRestRequest <CustomerContact>(restProperties, client);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                CustomerContact customerContact = Newtonsoft.Json.JsonConvert.DeserializeObject <CustomerContact>(response.Content);
                if (customerContact != null)
                {
                    customerContactVm.CutsomerContactId = customerContact.Id;
                    customerContactVm.CustomerId        = customerContact.CustomerId;
                    customerContactVm.CustomerName      = customerContact.Customer?.FirstName + " " + customerContact.Customer?.LastName;
                    customerContactVm.ContactTypeList   = new SelectList(contactTypes, "Id", "Type", customerContact.ContactTypeId);
                    customerContactVm.ContactTypeId     = customerContact.ContactTypeId;
                    customerContactVm.ContactTypeText   = customerContact.ContactType?.Type;
                    customerContactVm.ContactValue      = customerContact.ContactValue;
                    customerContactVm.ContactStatus     = customerContact.ContactStatus;
                    customerContactVm.ContactStatusList = new SelectList(ContactStatusList, "Key", "Value", customerContact.ContactStatus);
                }
            }
            else
            {
                throw new Exception("Error Message " + response.ErrorMessage + "\n  Exception:" + response.ErrorException);
            }
            return(customerContactVm);
        }
コード例 #30
0
        public int Add(CustomerContact customerContact)
        {
            string insertQuery = @"INSERT INTO [dbo].customercontact
                                                                   (
                                                                    contactGuid,
                                                                    FirstName, 
																	MiddleName,
																	LastName,
																	ContactTypeGuid,
																	PhoneNumber,
																	AltPhoneNumber,
																	EmailAddress,
																	AltEmailAddress,
																	Notes,
																	CustomerGuid,
                                                                    IsActive,
                                                                    IsDeleted, 
                                                                    CreatedOn, 
                                                                    UpdatedOn, 
                                                                    CreatedBy,
                                                                    UpdatedBy
                                                                    )
                                  VALUES (
                                                                    @contactGuid,
                                                                    @FirstName, 
																	@MiddleName,
																	@LastName,
																	@ContactTypeGuid,
																	@PhoneNumber,
																	@AltPhoneNumber,
																	@EmailAddress,
																	@AltEmailAddress,
																	@Notes,
																	@CustomerGuid,
                                                                    @IsActive,
                                                                    @IsDeleted, 
                                                                    @CreatedOn, 
                                                                    @UpdatedOn, 
                                                                    @CreatedBy,
                                                                    @UpdatedBy
                                                                )";

            return(_context.Connection.Execute(insertQuery, customerContact));
        }
コード例 #31
0
ファイル: UserService.cs プロジェクト: Geta/PayPal
        private CustomerContact CreateCustomerContact(SiteUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            CustomerContact contact = CustomerContact.CreateInstance();

            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
            // Send an email with this link
            // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
            // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
            // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

            if (!String.IsNullOrEmpty(user.FirstName) || !String.IsNullOrEmpty(user.LastName))
            {
                contact.FullName = String.Format("{0} {1}", user.FirstName, user.LastName);
            }

            contact.PrimaryKeyId       = new PrimaryKeyId(new Guid(user.Id));
            contact.FirstName          = user.FirstName;
            contact.LastName           = user.LastName;
            contact.Email              = user.Email;
            contact.UserId             = "String:" + user.Email; // The UserId needs to be set in the format "String:{email}". Else a duplicate CustomerContact will be created later on.
            contact.RegistrationSource = user.RegistrationSource;

            if (user.Addresses != null)
            {
                foreach (var address in user.Addresses)
                {
                    contact.AddContactAddress(address);
                }
            }

            // The contact, or more likely its related addresses, must be saved to the database before we can set the preferred
            // shipping and billing addresses. Using an address id before its saved will throw an exception because its value
            // will still be null.
            contact.SaveChanges();

            SetPreferredAddresses(contact);

            return(contact);
        }
コード例 #32
0
        public virtual void MapAddress(
            CustomerContact currentContact,
            CustomerAddressTypeEnum addressType,
            VippsAddress vippsAddress,
            string phoneNumber)
        {
            if (currentContact == null)
            {
                throw new ArgumentNullException(nameof(currentContact));
            }
            if (vippsAddress == null)
            {
                throw new ArgumentNullException(nameof(vippsAddress));
            }
            // Vipps addresses don't have an ID
            // They can be identified by Vipps address type
            var address =
                currentContact.ContactAddresses.FindVippsAddress(vippsAddress.AddressType);
            var isNewAddress = address == null;

            if (isNewAddress)
            {
                address             = CustomerAddress.CreateInstance();
                address.AddressType = addressType;
            }

            // Maps fields onto customer address:
            // Vipps address type, street, city, postalcode, countrycode
            MapVippsAddressFields(address, vippsAddress);
            if (!string.IsNullOrWhiteSpace(phoneNumber))
            {
                address.DaytimePhoneNumber = address.EveningPhoneNumber = phoneNumber;
            }

            if (isNewAddress)
            {
                currentContact.AddContactAddress(address);
            }
            else
            {
                currentContact.UpdateContactAddress(address);
            }
        }
コード例 #33
0
        private void newContact_Parm(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            TargetViewId = "CustomerContact_DetailView";
            IObjectSpace    objectSpace = Application.CreateObjectSpace();
            CustomerContact CustCont    = objectSpace.CreateObject <CustomerContact>();

            CustCont.Customers = objectSpace.GetObject <Customer>((Customer)View.CurrentObject);
            CustCont.State     = CustCont.Customers.BillingState;
            CustCont.Phone     = CustCont.Customers.Phone;
            CustCont.Address   = CustCont.Customers.BillingAddress;
            CustCont.Address2  = CustCont.Customers.BillingAddress2;
            CustCont.City      = CustCont.Customers.BillingCity;
            CustCont.Fax       = CustCont.Customers.Fax;
            CustCont.ZipCode   = CustCont.Customers.BillingZip;


            e.View         = Application.CreateDetailView(objectSpace, TargetViewId, true, CustCont);
            e.View.Caption = e.View.Caption + " - " + CustCont.Customers.CustomerName;
        }
コード例 #34
0
        public void RegisterAccount_WhenRegisterSuccessful_ShouldReturnJsonReturnUrl()
        {
            var identityResult = new IdentityResult();

            typeof(IdentityResult).GetProperty("Succeeded").SetValue(identityResult, true, null);

            _userServiceMock.Setup(
                x => x.RegisterAccount(It.IsAny <ApplicationUser>()))
            .Returns(Task.FromResult(new ContactIdentityResult
                                     (
                                         identityResult,
                                         CustomerContact.CreateInstance()
                                     )));

            var model = new RegisterAccountViewModel
            {
                Email      = "*****@*****.**",
                Newsletter = true,
                Password   = "******",
                Password2  = "Passwors@124#212",
            };

            model.Address = new AddressModel
            {
                Line1       = "Address",
                City        = "City",
                CountryName = "Country",
                FirstName   = "Fisrt Name",
                LastName    = "Last Name",
                PostalCode  = "952595",
                Email       = "*****@*****.**"
            };

            var result = _subject.RegisterAccount(model).Result as JsonResult;

            var expectedResult = new JsonResult
            {
                Data = new { ReturnUrl = "/" },
                JsonRequestBehavior = JsonRequestBehavior.DenyGet
            };

            result.ShouldBeEquivalentTo(expectedResult);
        }
コード例 #35
0
 /// <summary>
 /// Returns a new instance of a ContactIdentityResult.
 /// </summary>
 /// <param name="result">An IdentityResult created as part of an ASP.NET Identity action.</param>
 /// <param name="contact">A CustomerContact entity related to the IdentityResult.</param>
 public ContactIdentityResult(IdentityResult result, CustomerContact contact)
 {
     _contact = contact;
     _result = result;
 }
コード例 #36
0
        protected void PopulateCommonData(EntryContentBase content, IMarket currentMarket, CustomerContact currentContact)
        {
            Code = content.Code;
            ContentLink = content.ContentLink;
            DisplayName = content.DisplayName ?? content.Name;
            ProductUrl = _urlResolver.GetUrl(ContentLink);
            Description = content.GetPropertyValue("Description");
            Overview = content.GetPropertyValue("Overview");
            AverageRating = content.GetPropertyValue<double>("AverageRating");

            InStock = content.GetStock() > 0;

            ContentType = content.GetType().Name;

            if (string.IsNullOrEmpty(Overview))
                Overview = Description;

            CurrentContactIsCustomerClubMember = currentContact.IsCustomerClubMember();
        }
コード例 #37
0
ファイル: UserService.cs プロジェクト: adrian18hd/Quicksilver
        private void SetPreferredAddresses(CustomerContact contact)
        {
            var changed = false;

            var publicAddress = contact.ContactAddresses.FirstOrDefault(a => a.AddressType == CustomerAddressTypeEnum.Public);
            var preferredBillingAddress = contact.ContactAddresses.FirstOrDefault(a => a.AddressType == CustomerAddressTypeEnum.Billing);
            var preferredShippingAddress = contact.ContactAddresses.FirstOrDefault(a => a.AddressType == CustomerAddressTypeEnum.Shipping);

            if (publicAddress != null)
            {
                contact.PreferredShippingAddress = contact.PreferredBillingAddress = publicAddress;
                changed = true;
            }

            if (preferredBillingAddress != null)
            {
                contact.PreferredBillingAddress = preferredBillingAddress;
                changed = true;
            }

            if (preferredShippingAddress != null)
            {
                contact.PreferredShippingAddress = preferredShippingAddress;
                changed = true;
            }

            if (changed)
            {
                contact.SaveChanges();
            }
        }
コード例 #38
0
 /// <summary>
 /// This method inserts an relationship between customer and contact
 /// </summary>
 /// <param name="customerContact"></param>
 public void InsertCustomerContact(CustomerContact customerContact)
 {
     DbContext.CustomerContacts.InsertOnSubmit(customerContact);
     DbContext.SubmitChanges();
 }
コード例 #39
0
        protected Money? GetItemPrice(CatalogEntryDto.CatalogEntryRow entry, LineItem lineItem, CustomerContact customerContact)
        {
            List<CustomerPricing> customerPricing = new List<CustomerPricing>();
            customerPricing.Add(CustomerPricing.AllCustomers);
            if (customerContact != null)
            {
                var userKey = _mapUserKey.ToUserKey(customerContact.UserId);
                if (userKey != null && !string.IsNullOrWhiteSpace(userKey.ToString()))
                {
                    customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, userKey.ToString()));
                }

                if (!string.IsNullOrEmpty(customerContact.EffectiveCustomerGroup))
                {
                    customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, customerContact.EffectiveCustomerGroup));
                }
            }

            IPriceService priceService = ServiceLocator.Current.GetInstance<IPriceService>();

            PriceFilter priceFilter = new PriceFilter()
            {
                Currencies = new List<Currency>() { new Currency(lineItem.Parent.Parent.BillingCurrency) },
                Quantity = lineItem.Quantity,
                CustomerPricing = customerPricing,
                ReturnCustomerPricing = false // just want one value
            };
            // Get the lowest price among all the prices matching the parameters
            IPriceValue priceValue = priceService
                .GetPrices(lineItem.Parent.Parent.MarketId, FrameworkContext.Current.CurrentDateTime, new CatalogKey(entry), priceFilter)
                .OrderBy(pv => pv.UnitPrice)
                .FirstOrDefault();

            if (priceValue == null)
            {
                return null;
            }
            else
            {
                return priceValue.UnitPrice;
            }
        }
コード例 #40
0
ファイル: HomeModule.cs プロジェクト: MHAWeb/MachSecure.SCM
        public HomeModule()
        {
            Get["/"] = _ => View["index"];

            Post["api/newcall"] = _ =>
            {
                try
                {
                    var posts = this.Bind<NewCallObject>();
                    var rnd = new Random();

                    var sc = new SupportCall
                    {
                        RecordID = Guid.NewGuid(),
                        AssignedTo = Guid.Parse(posts.assignTo),
                        Customer = Guid.Parse(posts.contact),
                        CreatedBy = Guid.Parse(posts.createdBy),
                        CustomerReference = posts.customerRef,
                        CustomerSite = Guid.Parse(posts.location),
                        Product = Convert.ToInt32(posts.product),
                        InternalReference = "MHA" + rnd.Next(1736, 9999),
                        Status = 0,
                        CreatedDateTime = DateTime.Now,
                        UpdatedDateTime = DateTime.Now
                    };

                    var Initialnote = new Note
                    {
                        CallRecordID = sc.RecordID,
                        RecordID = Guid.NewGuid(),
                        CreatedBy = sc.CreatedBy,
                        NoteType = 6,
                        NoteSubType = Convert.ToInt32(posts.prc),
                        NoteText = posts.issueDescription,
                        TimeSpent = 0,
                        CreatedDateTime = DateTime.Now,
                        UpdatedDateTime = DateTime.Now
                    };

                    var note = new Note
                    {
                        CallRecordID = sc.RecordID,
                        RecordID = Guid.NewGuid(),
                        CreatedBy = sc.CreatedBy,
                        NoteType = 0,
                        NoteSubType = Convert.ToInt32(posts.prc),
                        NoteText = posts.prcDescription,
                        TimeSpent = 0,
                        CreatedDateTime = DateTime.Now,
                        UpdatedDateTime = DateTime.Now
                    };

                    if (sc.Save())
                    {
                        if (Initialnote.Save())
                        {
                            return note.Save() ? HttpStatusCode.OK : HttpStatusCode.BadRequest;
                        }
                        return HttpStatusCode.BadRequest;
                    }

                    return HttpStatusCode.BadRequest;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return HttpStatusCode.BadRequest;
                }
            };

            Get["api/supportCalls"] = _ =>
            {
                var calls = SupportCall.ToList();

                return Response.AsJson(calls);
            };

            Get["api/loadNotes/{id}"] = _ =>
            {
                var id = Guid.Parse(_.id);

                List<NoteDTO> notes = Note.LoadFromCall(id);

                return Response.AsJson(notes);
            };

            Get["api/export"] = _ =>
            {
                return Export.ExportToCSV();
            };

            Post["api/addNote"] = _ =>
            {
                var posts = this.Bind<NewNoteObject>();

                var note = new Note
                {
                    CreatedBy = Guid.Parse(posts.CreatedBy),
                    CallRecordID = Guid.Parse(posts.CallRecordID),
                    CreatedDateTime = DateTime.Now,
                    NoteSubType = Convert.ToInt32(posts.NoteSubType),
                    NoteText = posts.NoteText,
                    NoteType = Convert.ToInt32(posts.noteType),
                    RecordID = Guid.NewGuid(),
                    TimeSpent = Convert.ToDouble(posts.TimeSpent),
                    UpdatedDateTime = DateTime.Now
                };


                try
                {
                    if (note.Save())
                    {
                        SMTP.SendEmail("*****@*****.**", "Test Email", "This is a test e-mail");
                        return HttpStatusCode.OK;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return HttpStatusCode.BadRequest;
            };

            Post["api/addContact"] = _ =>
            {
                var posts = this.Bind<NewContact>();

                var con = new CustomerContact
                {
                    RecordID = Guid.NewGuid(),
                    CustomerSite = posts.customerSite,
                    Name = posts.Name,
                    Email = posts.Email,
                    PhoneNumber = posts.Phone,
                    MobileNumber = posts.Mobile,
                };

                try
                {
                    if (con.Save())
                    {
                        return HttpStatusCode.OK;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                return HttpStatusCode.BadRequest;
            };

            Post["api/updateContact"] = _ =>
            {
                var posts = this.Bind<UpdateContact>();
                var con = CustomerContact.Load(posts.RecordID);

                con.CustomerSite = posts.customerSite;
                con.Name = posts.Name;
                con.Email = posts.Email;
                con.PhoneNumber = posts.Phone;
                con.MobileNumber = posts.Mobile;

                try
                {
                    if (con.Save())
                    {
                        return HttpStatusCode.OK;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                Console.Write(CustomerContact.LastError.ToString());
                return HttpStatusCode.BadRequest;
            };

            Get["api/updateCall/{id}/{status}"] = _ =>
            {
                Guid g = Guid.Parse(_.id);
                int status = _.status;
                var sc = SupportCall.Load(g);

                sc.Status = status;

                try
                {
                    if (sc.Save())
                    {
                        return HttpStatusCode.OK;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                Console.Write(SupportCall.LastError.ToString());
                return HttpStatusCode.BadRequest;
            };

        }
コード例 #41
0
 public static CustomerContact CreateCustomerContact(int customerID, int customerEntityID)
 {
     CustomerContact customerContact = new CustomerContact();
     customerContact.CustomerID = customerID;
     customerContact.CustomerEntityID = customerEntityID;
     return customerContact;
 }
コード例 #42
0
 /// <summary>
 /// If customer has joined the members club, then add the interest areas to the
 /// customer profile.
 /// </summary>
 /// <remarks>
 /// The request to join the member club is stored on the order during checkout.
 /// </remarks>
 /// <param name="order">The order.</param>
 /// <param name="customer">The customer.</param>
 private void SetExtraCustomerProperties(PurchaseOrder order, CustomerContact customer)
 {
     if (UserHasRegisteredForMembersClub(order))
         UpdateCustomerWithMemberClubInfo(order, customer);
 }
コード例 #43
0
 private static void UpdateCustomerWithMemberClubInfo(PurchaseOrder order, CustomerContact customer)
 {
     customer.CustomerGroup = Constants.CustomerGroup.CustomerClub;
     customer.SetCategories(GetSelectedInterestCategoriesFrom(order));
     customer.SaveChanges();
 }
コード例 #44
0
        /// <summary>
        /// this method add the administrator of new company as contact of host'customer
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="userId"></param>
        private void AddContactInHostCustomer(Int32 customerId, Int32 userId)
        {
            var contactManager = new ContactManager(this);
            var customerContactManager = new CustomerContactManager(this);
            var profileManager = new ProfileManager(this);
            Profile profile = profileManager.GetProfileByUser(userId);
            var contact = new Contact
                              {
                                  Name = profile.Name,
                                  Phone = profile.Phone,
                                  CellPhone = profile.CellPhone,
                                  Address = profile.Address,
                                  AddressComp = profile.AddressComp,
                                  AddressNumber = profile.AddressNumber,
                                  Email = profile.Email,
                                  PostalCode = profile.PostalCode
                              };

            contactManager.Insert(contact);

            var customerContact = new CustomerContact();
            customerContact.CompanyId = GetHostCompany().CompanyId;
            customerContact.ContactId = contact.ContactId;
            customerContact.CustomerId = customerId;
            customerContactManager.Insert(customerContact);
        }
コード例 #45
0
 public void AddToCustomerContacts(CustomerContact customerContact)
 {
     base.AddObject("CustomerContacts", customerContact);
 }
コード例 #46
0
    /// <summary>
    /// This method inserts a new CustomerContact
    /// </summary>
    private void InsertCustomerContact()
    {
        var customerContact = new CustomerContact();

        customerContact.CompanyId = Company.CompanyId;
        customerContact.CustomerId = Convert.ToInt32(Request["CustomerId"]);
        customerContact.ContactId = Convert.ToInt32(selContact.ContactId);
        ContactManager.InsertCustomerContact(customerContact);
        grdContacts.DataBind();
    }