Ejemplo n.º 1
0
        public ContactOperationStatus Save(Contact contact)
        {
            var operationStatus = new ContactOperationStatus();
            try
            {
                if (_database.IsNew(contact))
                {
                    contact.ContactId=(int)_database.Insert(contact);
                    operationStatus.ContactCreated = true;
                }
                else
                {
                    _database.Update(contact);
                }
                operationStatus.Contact = contact;
                operationStatus.Status = true;
            }
            catch (Exception e)
            {
                operationStatus.LogFailedOperation(e);
                //operationStatus = OperationStatusExceptionHelper<ContactOperationStatus>
                //    .CreateFromException("An error has occurred retrieving the contact from the queue", e);

            }
            return operationStatus;
        }
Ejemplo n.º 2
0
        public Order UpdateDiscount(Order order,Contact contact)
        {
            if (order.NumberOfItems >= _qty)
            {
                decimal discountTotal = 0;

                //loops through each item, to match functionality in current
                //Publications database
                foreach (OrderLine item in order.CurrentOrderLines)
                {

                    decimal discountOnRow =
                        Decimal.Round(
                            Decimal.Multiply((Decimal.Divide(_perCent, Convert.ToDecimal(100))),
                                             (Convert.ToDecimal(item.PaymentLineTotal))), 2);
                    order.CurrentOrderLines.First(x => x.OrderLineId == item.OrderLineId).LineDiscount = discountOnRow;
                    discountTotal = Decimal.Round(Decimal.Add(discountTotal, discountOnRow), 2);
                }
                order.DiscountTotal = discountTotal;
                order.DiscountInfo = "Since twenty or more items are ordered, a 10% discount is applied.";
            }
            else
            {
                order.DiscountTotal = 0;
                order.DiscountInfo =
                    "No discount has been applied on this order.  If you order twenty or more items, a 10% discount is applied.";
            }
            return order;
        }
Ejemplo n.º 3
0
 public OrderOperationStatus GetOrder(Contact contact, int orderIndex)
 {
     var orderOperationStatus = _orderRepository.GetOrder(contact, orderIndex);
     if (orderOperationStatus.Status)
     {
         orderOperationStatus.Order = GetOrderConfiguration(orderOperationStatus.Order);
     }
     return orderOperationStatus;
 }
Ejemplo n.º 4
0
        public OrderOperationStatus GetOrder(Contact contact, int orderIndex)
        {
            var operationStatus = new OrderOperationStatus();
            try
            {
                var sql = Sql.Builder
                    .Select("*")
                    .From("cpxOrder");

                sql.Append("WHERE status='PROV' AND OrderIndex=@0",orderIndex);

                if (contact.ContactId > 0)
                {
                    sql.Append("AND ContactId=@0", contact.ContactId);
                }
                else
                    sql.Append("AND UserId=@0", contact.UserId);

                var order =
                    _database.SingleOrDefault<Order>(sql);

                //if no order found with contact id, try user id
                if (contact.ContactId > 0 & order == null)
                {
                    sql = Sql.Builder
                             .Select("*")
                             .From("cpxOrder")
                             .Where("status='PROV' AND OrderIndex=@0 AND UserId=@1",orderIndex,contact.UserId);
                    order = _database.SingleOrDefault<Order>(sql);
                }

                if (order == null)
                {
                    order = CreateOrder(contact, orderIndex);
                }
                if (contact.ContactId != order.ContactId)
                {
                    order.ContactId = contact.ContactId;
                    _database.Update(order);
                }

                order.OrderLines = _database.Fetch<OrderLine>("SELECT * FROM cpxOrderLines WHERE OrderId=@0",order.OrderId);
                operationStatus.Order = order;
                operationStatus.Status = true;
            }
            catch (Exception e)
            {
                operationStatus = OperationStatusExceptionHelper<OrderOperationStatus>
                    .CreateFromException("An error has occurred retrieving the order", e);
            }
            return operationStatus;
        }
        public static void Initialise(TestContext context)
        {
            _existingUserCredentials = new Contact {UserId = "1234", UserName = "******"};
            _newUserCredentials = new Contact
                {
                    UserId = Guid.NewGuid().ToString(),
                    UserName = Guid.NewGuid().ToString()
                };

            var database = new Database(ConfigurationManager.AppSettings["umbracoDbDSN"],
                                                 "System.Data.SqlClient");
            _orderRepository = new OrderRepository(database);
        }
        public ContactAuthenticationOperationStatus CreateContact(Contact contact)
        {
            var operationStatus= new ContactAuthenticationOperationStatus();
            try
            {
                var createStatus = new MembershipCreateStatus();
                var newUser = Membership.CreateUser(contact.UserName, contact.Password, contact.Email, "Question", "Answer", true, out createStatus);

                switch (createStatus)
                {
                    case MembershipCreateStatus.Success:
                        System.Web.Security.FormsAuthentication.SetAuthCookie(contact.UserName, true);
                        operationStatus.Status = true;
                        Roles.AddUserToRole(contact.UserName, "Customer");
                        operationStatus.Message = "Your account has been successfully created.";
                        break;
                    case MembershipCreateStatus.DuplicateUserName:
                        operationStatus.Status = false;
                        operationStatus.Message =
                            "That email address is already registered with us. If you know what your password is, please just login using your email address and password.  If you have already registered with us and can't remember your password, please use the Password recovery link to reset your password.";
                        break;
                    case MembershipCreateStatus.DuplicateEmail:
                        operationStatus.Status = false;
                        operationStatus.Message =
                            "A user with that Email address already exists.  If you have already registered with us and can't remember your password, please use the Password recovery link to reset your password.";
                        break;
                    case MembershipCreateStatus.InvalidEmail:
                        operationStatus.Status=false;
                        operationStatus.Message = "Please enter a VALID email address.";
                        break;
                    case MembershipCreateStatus.InvalidAnswer:
                        operationStatus.Status = false;
                        operationStatus.Message = "The security answer is not valid";
                        break;
                    case MembershipCreateStatus.InvalidPassword:
                        operationStatus.Status = false;
                        operationStatus.Message = "The password entered is invalid. Please enter a passoword with at least 7 characters and one non-alphanumeric.";
                        break;
                    default:
                        operationStatus.Status = false;
                        operationStatus.Message = "Unknown Error: Account NOT created." ;
                        break;
                }
            }
            catch (Exception e)
            {
                operationStatus = OperationStatusExceptionHelper<ContactAuthenticationOperationStatus>
                    .CreateFromException("An error has occurred creating the user", e);
            }
            return operationStatus;
        }
        public void CreateContactWithEmailAddressAndTelephone()
        {
            Contact contact = new Contact();

            contact.Title = "Mr";
            contact.FirstName = "James";
            contact.LastName = "Drever";
            contact.Address1 = "83 Oakfield Road";
            contact.Town = "Shrewsbury";
            contact.County = "Shropshire";
            contact.Country = "UK";
            contact.Email = "*****@*****.**";
            contact.Telephone = "01743 852107";
            CareContactSynchroniser test = new CareContactSynchroniser();
            ContactOperationStatus operationStatus=test.SaveContact(contact);
            Assert.IsTrue(operationStatus.ContactQueued == true);
        }
Ejemplo n.º 8
0
        public void Initialise()
        {
            var product = new Product
                {
                    ProductId = 29397,
                    ProductType = "P",
                    OrderIndex = 1,
                    Price = 3,
                    Title = "Test Product"
                };
            var product2 = new Product
                {
                    ProductId = 29398,
                    ProductType = "P",
                    OrderIndex = 1,
                    OptionId = 30001,
                    Price = 3,
                    Title = "Test Product with Option"
                };

            var productRepository = new Mock<IProductRepository>();
            productRepository.Setup(x => x.GetProduct(It.Is<int>(i => i == 29397),It.Is<int>(i => i==0)))
                             .Returns(new ProductOperationStatus {Product = product, Status = true});
            productRepository.Setup(x => x.GetProduct(It.Is<int>(i => i == 29398),It.Is<int>(i=>i==30001)))
                             .Returns(new ProductOperationStatus {Product = product2, Status = true});

            var voucherRepository = new Mock<IVoucherRepository>();

            var contactRepository = new Mock<IContactRepository>();
            Contact contact = new Contact {UserId = "1234", UserName = "******"};
            contactRepository.Setup((x => x.GetContact()))
                             .Returns(new ContactOperationStatus { Status = true, Contact = contact} ); //need to create UpdatedContact details new UpdatedContact
            var orderRepository = new Mock<IOrderRepository>();
            orderRepository.Setup(x => x.Add(It.IsAny<Product>(), It.IsAny<int>(), It.IsAny<string>(),It.IsAny<decimal>(),It.IsAny<Contact>()))
                           .Returns(new OrderOperationStatus {Status = true});
            orderRepository.Setup(x => x.Update(It.IsAny<Product>(),It.IsAny<Product>(), It.IsAny<int>(),It.IsAny<string>(), It.IsAny<decimal>(),It.IsAny<Contact>()))
                           .Returns(new OrderOperationStatus {Status = true});
            orderRepository.Setup(x => x.Remove(It.IsAny<Product>(), It.IsAny<Contact>()))
                           .Returns(new OrderOperationStatus {Status = true});
            orderRepository.Setup(x => x.UpdateSpecialRequirements(It.IsAny<string>(),It.IsAny<int>(),It.IsAny<Contact>()))
                           .Returns(new OrderOperationStatus { Status = true });
            var configService = new Mock<IConfigurationService>();
            configService.Setup(x => x.GetConfiguration()).Returns(new CustomerPortalSection());
            _ecommerceService = new EcommerceService(orderRepository.Object, productRepository.Object, voucherRepository.Object,
                                                     contactRepository.Object, configService.Object);
        }
Ejemplo n.º 9
0
 public OrderOperationStatus QueueOrder(Order order, Contact contact)
 {
     var operationStatus = new OrderOperationStatus();
     try
     {
         SendEmails(order, contact);
         _additionalQueueProcessingHandlerFactory.GetHandler(order.AdditionalQueueProcessingHandler).PerformAdditionalProcessing(order,contact);
         order.Status = "QUE";
         order.UpdateOrderLines("QUE");
         _orderRepository.SaveOrder(order);
         operationStatus.Order = order;
         operationStatus.Status = true;
     }
     catch (Exception e)
     {
         operationStatus = OperationStatusExceptionHelper<OrderOperationStatus>
             .CreateFromException("An error has occurred processing the order", e);
     }
     return operationStatus;
 }
Ejemplo n.º 10
0
        private ProfileBase SaveToProfile(Contact contact,ProfileBase profile)
        {
            profile.SetPropertyValue("customer_title",contact.Title);
            profile.SetPropertyValue("customer_first_name", contact.FirstName);
            profile.SetPropertyValue("customer_last_name",contact.LastName);
            profile.SetPropertyValue("customer_address_1",contact.Address1);
            profile.SetPropertyValue("customer_address_2", contact.Address2);
            profile.SetPropertyValue("customer_address_3", contact.Address3);
            profile.SetPropertyValue("customer_town",contact.Town);
            profile.SetPropertyValue("customer_county",contact.County);
            profile.SetPropertyValue("customer_country", contact.Country);
            profile.SetPropertyValue("customer_postcode",contact.Postcode);

            profile.SetPropertyValue("customer_mobile",contact.Mobile);
            profile.SetPropertyValue("customer_telephone",contact.Telephone);
            profile.SetPropertyValue("customer_separate_delivery_address", contact.SeparateDeliveryAddress);
            profile.SetPropertyValue("customer_delivery_address1",contact.DeliveryAddress1);
            profile.SetPropertyValue("customer_delivery_address2", contact.DeliveryAddress2);
            profile.SetPropertyValue("customer_delivery_address3", contact.DeliveryAddress3);
            profile.SetPropertyValue("customer_delivery_town", contact.DeliveryTown);
            profile.SetPropertyValue("customer_delivery_county", contact.DeliveryCounty);
            profile.SetPropertyValue("customer_delivery_postcode", contact.DeliveryPostcode);
            profile.SetPropertyValue("customer_delivery_country",contact.DeliveryCountry);
            profile.SetPropertyValue("care_contact_number", contact.ExternalContactNumber.ToString());
            profile.SetPropertyValue("care_address_number", contact.ExternalAddressNumber.ToString());
            profile.Save();

            //TODO: what to do with updating email addresses?
            try
            {

                //having to update membership in this convoluted way because of Umbraco bug
                //see http://umbraco.codeplex.com/workitem/30789

                var updateMember = Membership.GetUser(contact.UserName);
                var m = new umbraco.cms.businesslogic.member.Member((int)updateMember.ProviderUserKey);
                m.LoginName = contact.Email;
                m.Email = contact.Email;
                m.Save();
                FormsAuthentication.SetAuthCookie(contact.Email, true);

             }
            catch (Exception e)
            {
                string err=e.ToString();
            }
            return profile;
        }
Ejemplo n.º 11
0
        private Contact LoadFromProfile(ProfileBase profile)
        {
            Contact contact = new Contact();
            if (profile.UserName == null)
            {
                contact.Status = false;
            }
            else
            {
                contact.UserName = profile.UserName;
                contact.Title = (string)profile.GetPropertyValue("customer_title");
                contact.Address1 = (string)profile.GetPropertyValue("customer_address_1");
                contact.Address2 = (string)profile.GetPropertyValue("customer_address_2");
                contact.Address3 = (string)profile.GetPropertyValue("customer_address_3");
                contact.Town = (string)profile.GetPropertyValue("customer_town");
                contact.County = (string)profile.GetPropertyValue("customer_county");
                contact.Country = (string)profile.GetPropertyValue("customer_country");
                if (contact.Country == "United Kingdom") contact.Country = "UK";
                if (contact.Country.Length > 5) contact.Country = "";
                contact.Postcode = (string)profile.GetPropertyValue("customer_postcode");
                contact.FirstName = (string)profile.GetPropertyValue("customer_first_name");
                contact.LastName = (string)profile.GetPropertyValue("customer_last_name");
                contact.Email = Membership.GetUser(profile.UserName).Email;
                contact.Mobile = (string)profile.GetPropertyValue("customer_mobile");
                contact.Telephone = (string)profile.GetPropertyValue("customer_telephone");
                contact.SeparateDeliveryAddress = (profile.GetPropertyValue("customer_separate_delivery_address").ToString() == "1");
                contact.DeliveryAddress1 = (string)profile.GetPropertyValue("customer_delivery_address1");
                contact.DeliveryAddress2 = (string)profile.GetPropertyValue("customer_delivery_address2");
                contact.DeliveryAddress3 = (string)profile.GetPropertyValue("customer_delivery_address3");
                contact.DeliveryTown = (string)profile.GetPropertyValue("customer_delivery_town");
                contact.DeliveryCounty = (string)profile.GetPropertyValue("customer_delivery_county");
                contact.DeliveryPostcode = (string)profile.GetPropertyValue("customer_delivery_postcode");
                contact.DeliveryCountry = (string)profile.GetPropertyValue("customer_delivery_country");
                if (contact.DeliveryCountry == "United Kingdom") contact.DeliveryCountry = "UK";
                if (contact.DeliveryCountry.Length > 5) contact.DeliveryCountry = "";
                int externalContactNumber = 0;
                int.TryParse(profile.GetPropertyValue("care_contact_number").ToString(), out externalContactNumber);
                int externalAddressNumber = 0;
                int.TryParse(profile.GetPropertyValue("care_address_number").ToString(), out externalAddressNumber);
                contact.ExternalContactNumber = externalContactNumber;
                contact.ExternalAddressNumber = externalAddressNumber;
                contact.Status = true;

                //get the contact id
                //var getMember = Membership.GetUser(contact.UserName);
                //var m = new umbraco.cms.businesslogic.member.Member((int)getMember.ProviderUserKey);
                //contact.ContactId = m.Id;
            }
            return contact;
        }
Ejemplo n.º 12
0
 private void CreateProfile(Contact contact)
 {
     SaveToProfile(contact, ProfileBase.Create(contact.UserName));
     Roles.AddUserToRole(contact.UserName, "Customer");
 }
Ejemplo n.º 13
0
        private ContactOperationStatus CreateContact(Contact contact)
        {
            MembershipCreateStatus createStatus = new MembershipCreateStatus();
            MembershipUser newUser = Membership.CreateUser(contact.UserName, contact.Password,contact.Email, "Question", "Answer", true, out createStatus);

            ContactOperationStatus returnStatus;

            switch (createStatus)
            {
                case MembershipCreateStatus.Success:
                    System.Web.Security.FormsAuthentication.SetAuthCookie(contact.UserName, true);
                    CreateProfile(contact);
                    returnStatus = new ContactOperationStatus { Status = true, Message = "Your account has been successfully created." };
                    break;
                case MembershipCreateStatus.DuplicateUserName:
                    returnStatus = new ContactOperationStatus { Status = false, Message = "That username already exists.  If you have already registered with us and can't remember your password, please use the Password recovery link to reset your password." };
                    break;
                case MembershipCreateStatus.DuplicateEmail:
                    returnStatus = new ContactOperationStatus { Status = false, Message = "A user with that Email address already exists.  If you have already registered with us and can't remember your password, please use the Password recovery link to reset your password." };
                    break;
                case MembershipCreateStatus.InvalidEmail:
                    returnStatus = new ContactOperationStatus { Status = false, Message = "Please enter a VALID email address." };
                    break;
                case MembershipCreateStatus.InvalidAnswer:
                    returnStatus = new ContactOperationStatus { Status = false, Message = "The security answer is not valid" };
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    returnStatus = new ContactOperationStatus { Status = false, Message = "The password entered is invalid. Please enter a passoword with at least 7 characters and one non-alphanumeric." };
                    break;
                default:
                    returnStatus = new ContactOperationStatus { Status = false, Message = "Unknown Error: Account NOT created." };
                    break;
            }

            return returnStatus;
        }
        public void UpdateContact()
        {
            Contact contact = new Contact();

            contact.Title = "Mr";
            contact.FirstName = "James";
            contact.LastName = "Drever";
            contact.Address1 = "83 Oakfield Road";
            contact.Town = "Shrewsbury";
            contact.County = "Shropshire";
            contact.Country = "UK";

            CareContactSynchroniser test = new CareContactSynchroniser();
            ContactOperationStatus createdContact = test.SaveContact(contact);
        }
Ejemplo n.º 15
0
 private Order CreateOrder(Contact contact, int orderIndex)
 {
     var order = new Order {UserId = contact.UserId, UserName = contact.UserName, ContactId=contact.ContactId,OrderIndex = orderIndex,GiftAidAgreement = contact.GiftAidAgreement};
     order.OrderId = (int) _database.Insert("cpxOrder", "OrderId", true, order);
     return order;
 }
Ejemplo n.º 16
0
        public OrdersOperationStatus GetOrders(Contact contact)
        {
            var operationStatus = new OrdersOperationStatus();
            try
            {
                var sql = Sql.Builder
                    .Select("*")
                    .From("cpxOrder")
                    .Where("status='PROV'");

                if (contact.ContactId > 0)
                    sql.Append("AND ContactId=@0", contact.ContactId);
                else
                    sql.Append("AND UserId=@0", contact.UserId);

                var orders =
                    _database.Fetch<Order>(sql);

                for (int i=0;i<orders.Count;i++)
                {
                    if (contact.ContactId != orders[i].ContactId)
                    {
                        orders[i].ContactId = contact.ContactId;
                        _database.Update(orders[i]);
                    }
                    orders[i].OrderLines = _database.Fetch<OrderLine>("SELECT * FROM cpxOrderLines WHERE OrderId=@0", orders[i].OrderId);
                }
                operationStatus.Orders = orders;
                operationStatus.Status = true;
            }
            catch (Exception e)
            {
                operationStatus.LogFailedOperation(e,"An error has occurred updating the order");
            }
            return operationStatus;
        }
Ejemplo n.º 17
0
        public ContactOperationStatus SaveContact(Contact contact)
        {
            if (String.IsNullOrEmpty(contact.UserName))
                contact.UserName = contact.Email;

            //if the user isn't already logged in
            if (contact.ContactId==0)
            {
                //create an authentication
                var authenticationOperationStatus=_authenticationHandler.CreateContact(contact);
                if (!authenticationOperationStatus.Status)
                {
                    return
                        (ContactOperationStatus) new ContactOperationStatus().InjectFrom(authenticationOperationStatus);
                }

            }

            //save the contact locally
            ContactOperationStatus operationStatus = _contactRepository.Save(contact);

            if (operationStatus.Status)
            {
                if (operationStatus.ContactCreated)
                    _authenticationHandler.SetContactId(contact.UserName,contact.ContactId);

                contact = operationStatus.Contact;

                //if the contact can be synced
                if (_contactSynchroniser.SynchronisationAvailable())
                {
                    //sync it
                    operationStatus = _contactSynchroniser.SaveContact(contact);
                }
                operationStatus.Message = "Your details have been successfully updated.";
            }
            return operationStatus;
        }
Ejemplo n.º 18
0
        public ContactOperationStatus GetContact()
        {
            var operationStatus=new ContactOperationStatus();
            int contactId = 0;
            try
            {
                //if the user logged in?
                if (_authenticationHandler.IsCurrentUserLoggedIn())
                {
                    //if yes, get the ContactId
                    contactId = _authenticationHandler.GetContactId();
                    //if there is one, get the contact
                    if (contactId>0)
                        operationStatus = _contactRepository.Get(contactId);
                    else
                    {
                        operationStatus.Status = false;
                    }
                    //if no luck with contact repository, try secondary repository, if it is active
                    if (!operationStatus.Status&&_secondaryContactRepository.RepositoryAvailable())
                    {
                        string userName = _authenticationHandler.GetUserName();
                        operationStatus = _secondaryContactRepository.Get(userName);
                        if (operationStatus.Status)
                        {
                            operationStatus = _contactRepository.Save(operationStatus.Contact);
                            if (operationStatus.Status)
                                _authenticationHandler.SetContactId(operationStatus.Contact.UserName,operationStatus.Contact.ContactId);
                        }
                    }
                    if (operationStatus.Status)
                    {
                        Contact contact = operationStatus.Contact;

                        contact.CountryDesc = _contactSynchroniser.GetCountry(contact.Country).Name;
                        if (contact.SeparateDeliveryAddress)
                            contact.DeliveryCountryDesc = _contactSynchroniser.GetCountry(contact.DeliveryCountry).Name;

                        //check if the UserId for the contact needs updating
                        string currentUserId = _authenticationHandler.GetUserId();
                        string currentReferrerdId = _authenticationHandler.GetReferrerId();
                        if (contact.UserId != currentUserId||contact.ReferrerId!=currentReferrerdId)
                        {
                            contact.UserId = currentUserId;
                            contact.ReferrerId = currentReferrerdId;
                            _contactRepository.Save(contact);

                        }
                        contact.ReferrerId = _authenticationHandler.GetReferrerId();

                        if (_contactSynchroniser.SynchronisationAvailable() &&
                            _contactSynchroniser.CanContactBeSynced(contact))
                        {
                            operationStatus = _contactSynchroniser.GetContact(contact.ExternalContactNumber);
                            if (operationStatus.Status)
                            {
                                //merge in changes from sync
                                contact.InjectFrom<IgnoreNulls>(operationStatus.Contact);
                                contact.ContactId = contactId;
                                //update the repository with the changes
                                operationStatus = _contactRepository.Save(contact);
                            }
                        }
                    }
                }
                else
                {
                    Contact contact = new Contact();
                    contact.UserId = _authenticationHandler.GetUserId();
                    contact.ReferrerId = _authenticationHandler.GetReferrerId();
                    contact.Status = false;
                    operationStatus.Contact = contact;
                    operationStatus.Status = true;
                }

            }
            catch (Exception e)
            {
                operationStatus.LogFailedOperation(e);
                //operationStatus = OperationStatusExceptionHelper<ContactOperationStatus>
                //       .CreateFromException("An error has occurred getting the contact", e);

            }
            return operationStatus;
        }
Ejemplo n.º 19
0
 public Order UpdateDiscount(Order order, Contact contact)
 {
     return order;
 }
 ContactOperationStatus IContactSynchroniser.SaveContact(Contact contact)
 {
     throw new NotImplementedException();
 }
 bool IContactSynchroniser.CanContactBeSynced(Contact contact)
 {
     return false;
 }
Ejemplo n.º 22
0
        private ContactOperationStatus UpdateContact(Contact contact)
        {
            try
            {
                var checkMember = Membership.GetUserNameByEmail(contact.Email);
                //var profile = ProfileBase.Create(contact.Email);
                if (!String.IsNullOrEmpty(checkMember) && contact.ExistingEmail != contact.Email)
                {
                    return new ContactOperationStatus
                        {
                            Status = false,
                            MessageCode = "CP.EmailAlreadyExists",
                            Message = "This email address is already registered on our system."
                        };

                }
                SaveToProfile(contact,ProfileBase.Create(contact.ExistingUserName));
                return new ContactOperationStatus
                {
                    Status = true, Message = "Your account has been successfully updated.", Contact = contact
                };
            }
            catch (Exception e)
            {
                return OperationStatusExceptionHelper<ContactOperationStatus>
                    .CreateFromException("An error has occurred updating your information", e);
            }
        }
Ejemplo n.º 23
0
        private void SendEmails(Order order, Contact contact)
        {
            //TODO: email content needs to be editable

            var mailBodyNotification = new StringBuilder();
            var mailBodyCustomer = new StringBuilder();
            var mailBodyCourses = new StringBuilder();
            var mailBodyMemberships = new StringBuilder();
            var mailBodyDonations = new StringBuilder();

            bool sendMail = false;

            mailBodyNotification.Append("<p>Contact Details</p>");
            mailBodyNotification.AppendFormat("<p>Name: {0} {1} {2}</p>", contact.Title, contact.FirstName,
                                              contact.LastName);
            mailBodyNotification.AppendFormat("<p>Address: {0}<br />{1}<br />{2}<br />{3}<br />{4}<br />{5}</p>",
                                              contact.Address1, contact.Address2, contact.Town, contact.County,
                                              contact.Postcode,
                                              contact.CountryDesc);
            mailBodyNotification.AppendFormat("<p>Telephone : {0}\nMobile: {1}</p>", contact.Telephone, contact.Mobile);
            mailBodyNotification.AppendFormat("<p>Email: {0}</p>", contact.Email);

            if (order.ContainsCourses())
            {
                sendMail = true;

                mailBodyNotification.Append("<p>This person has booked the following courses:</p>");

                mailBodyCustomer.Append(
                    "Thank you for requesting the course(s) below. The centre(s) running them will confirm availability and contact you shortly.");

                //create the main email first
                //loop through each item in the cart and add it to the email body
                foreach (OrderLine orderLine in order.GetCourseOrderLines())
                {

                    mailBodyCourses.AppendFormat("<p><b>Course: {0} {1}</b></p>", orderLine.ProductTitle,
                                                 orderLine.ProductDescription);
                    mailBodyCourses.AppendFormat("<p>Booking Option: {0} &#163;{1}</p>", orderLine.ProductOptionTitle,
                                                 orderLine.ProductPrice);
                    mailBodyCourses.AppendFormat("<p>Number of attendees: {0}", orderLine.Quantity);
                    mailBodyCourses.AppendFormat("<p>Payment Made Per attendee: &#163;{0}</p>", orderLine.PaymentAmount);
                    mailBodyCourses.AppendFormat("<p>Total Payment: &#163;{0}</p>", orderLine.PaymentLineTotal);
                }
                mailBodyCourses.AppendFormat("<p>Special Requirements: {0}</p>", order.SpecialRequirements);

                //create the centre emails next
                //loop through each centre and check whether they have any bookings

                var locationEmails = order.GetLocationEmails();

                foreach (string email in locationEmails)
                {
                    var mailBodyLocation = new StringBuilder();
                    string locationEmail = email;
                    bool foundCourses = false;
                    foreach (OrderLine orderLine in order.CurrentOrderLines.Where(x => x.LocationEmail == locationEmail))
                    {
                        //if there is a booking for this centre, add it to the centre email

                        foundCourses = true;
                        mailBodyLocation.AppendFormat("<p><b>Course: {0} {1}</b></p>", orderLine.ProductTitle,
                                                      orderLine.ProductDescription);
                        mailBodyLocation.AppendFormat("<p>Booking Type: {0}</p>",
                                                      orderLine.PaymentTypeDescription);

                        mailBodyLocation.AppendFormat("<p>Booking Option: {0} &#163;{1}</p>",
                                                      orderLine.ProductOptionTitle,
                                                      orderLine.ProductPrice);
                        mailBodyLocation.AppendFormat("<p>Number of attendees: {0}", orderLine.Quantity);
                        mailBodyLocation.AppendFormat("<p>Total Payment: &#163;{0}</p>", orderLine.PaymentLineTotal);

                    }
                    //send the centre email
                    if (foundCourses)
                    {
                        mailBodyLocation.AppendFormat("<p>Special Requirements: {0}</p>", order.SpecialRequirements);
                        if (order.HasValidVoucher())
                        {
                            mailBodyLocation.AppendFormat("<p><b>The following voucher has been applied to this order: {0} {1}.</b></p>", order.VoucherInfo, order.GetVoucherDetail());
                        }

                        SendEmail("*****@*****.**", locationEmail,
                                  "WEBSITE Individuals and Families Booking",
                                  mailBodyNotification.ToString() + mailBodyLocation.ToString());
                    }
                }

                mailBodyNotification.Append(mailBodyCourses);
                mailBodyCustomer.Append(mailBodyCourses);

            }
            if (order.ContainsProductType("M"))
            {
                sendMail = true;

                mailBodyNotification.Append("<p>This person has requested the following membership:</p>");

                mailBodyCustomer.Append(
                    "<p>Thank you for joining FSC.  Your membership will support our work to inspire young people to understand and experience the natural world including the wider benefits that a greater appreciation of nature can bring.</p>");
                mailBodyCustomer.Append(
                    "<p>A welcome pack will be sent to you by post within 2-3 weeks. You will receive a membership card that is renewed annually.  We produce a members’ magazine FSC Magazine twice a year and you will also receive access to an exclusive members’ preview of the annual leisure learning and professional development programme.</p>");

                foreach (OrderLine orderLine in order.GetMembershipOrderLines())
                {

                    mailBodyMemberships.AppendFormat("<p><b>{0} {1}</b></p>", orderLine.ProductTitle,
                                                     orderLine.ProductDescription);
                    mailBodyMemberships.AppendFormat("<p>Total Payment: &#163;{0}</p>", orderLine.PaymentLineTotal);
                }
                mailBodyNotification.Append(mailBodyMemberships);
                mailBodyCustomer.Append(mailBodyMemberships);
            }

            if (order.ContainsProductType("D"))
            {

                sendMail = true;

                mailBodyNotification.Append("<p>This person has made the following donation(s):</p>");

                mailBodyCustomer.Append(
                    "<p>Thank you for your donation which will support our work to inspire young people to understand and experience the natural world including the wider benefits that a greater appreciation of nature can bring.</p>");

                foreach (OrderLine orderLine in order.GetDonationOrderLines())
                {

                    mailBodyDonations.AppendFormat("<p><b>{0} {1}</b></p>", orderLine.ProductTitle,
                                                   orderLine.ProductDescription);
                    mailBodyDonations.AppendFormat("<p>Total Payment: &#163;{0}</p>", orderLine.PaymentLineTotal);
                }
                mailBodyNotification.Append(mailBodyDonations);
                mailBodyCustomer.Append(mailBodyDonations);

            }

            if (order.GiftAidAgreement)
            {
                mailBodyNotification.Append("<p><b>This person has made a Gift Aid Agreement.</b></p>");

                mailBodyCustomer.Append(
                    "Thank you for making a Gift Aid declaration.");
            }

            if (order.HasValidVoucher())
            {
                mailBodyNotification.AppendFormat("<p><b>The following voucher has been applied to this order: {0} {1}.</b></p>", order.VoucherInfo, order.GetVoucherDetail());
                mailBodyCustomer.AppendFormat("<p><b>The following voucher has been applied to your order: {0} {1}.</b></p>", order.VoucherInfo, order.GetVoucherDetail());
            }

            if (sendMail)
            {

                //send the notification email
                SendEmail("*****@*****.**", "*****@*****.**",
                          "WEBSITE Individuals and Families Booking",
                          mailBodyNotification.ToString());
                //send the customer email
                SendEmail("*****@*****.**", contact.Email, "FSC Individuals and Families Booking",
                          mailBodyCustomer.ToString());
            }
        }
Ejemplo n.º 24
0
        public Order UpdateOrderWithShippingAndDiscounts(Order order, Contact contact)
        {
            IOrderTypeSetting orderTypeSetting =
            _config.GetConfiguration().OrderTypeSettings[order.OrderIndex.ToString()];

            string shippingConfig = (orderTypeSetting != null)
                                        ? orderTypeSetting.ShippingHandler
                                        : _config.GetConfiguration().ShippingHandler;
            order = _shippingHandlerFactory.getShippingHandler(shippingConfig).UpdateShipping(order, contact);

            string discountConfig = (orderTypeSetting != null)
                                        ? orderTypeSetting.DiscountHandler
                                        : _config.GetConfiguration().DiscountHandler;
            order = _discountHandlerFactory.getDiscountHandler(discountConfig).UpdateDiscount(order, contact);
            return order;
        }
Ejemplo n.º 25
0
 public OrderOperationStatus ProcessOrder(Order order, Contact contact)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 26
0
 public Order UpdateShipping(Order order, Contact contact)
 {
     return order;
 }
Ejemplo n.º 27
0
 public OrderOperationStatus GetOrder(Contact contact)
 {
     return GetOrder(contact, 1);
 }
Ejemplo n.º 28
0
 public ContactOperationStatus SaveContact(Contact contact)
 {
     //if user already exists
     if (!String.IsNullOrEmpty(contact.ExistingUserName)&&Membership.GetUser(contact.ExistingUserName)!=null)
     {
         //update the profile
         return UpdateContact(contact);
     }
     else
     {
         //otherwise create a new profile
         return CreateContact(contact);
     }
 }
        public Order UpdateShipping(Order order, Contact contact)
        {
            if (order.NumberOfItems == 0)
            {
                order.ShippingTotal = 0;
                return order;
            }

            //default country to UK if not specified
            string country = (String.IsNullOrEmpty(contact.Country)) ? "United Kingdom" : contact.Country;

            decimal total = (decimal) order.PaymentSubTotalIncludingDiscountAndVoucher;
            order.ShippingInfo = "Shipping based on delivery to " + country;
            if (country == "United Kingdom - Mainland" || country == "United Kingdom" || country == "UK")
            {
                if (total > 0 && total <= (decimal) 6.50)
                {
                    order.ShippingTotal = 1;
                    return order;
                }
                if (total <= 15 && total > 6)
                {
                    order.ShippingTotal = 2;
                    return order;
                }
                if (total <= 30 && total > 15)
                {
                    order.ShippingTotal = 3;
                    return order;
                }
                if (total <= 100 && total > 30)
                {
                    order.ShippingTotal = 5;
                    return order;
                }
                if (total <= 150 && total > 100)
                {
                    order.ShippingTotal = 8;
                    return order;
                }
                order.ShippingTotal = 0;
                return order;
            }
            /*
            Offshore post
            Upto £6.50 - £1
            £6.51to £15 - £2
            £15.01-30 - £3
            £30.01-£100 - £5
            £100.01-£150 - £12
            £150.05 and over - £15
            */
            if (country == "United Kingdom - Islands" || country == "UKI")
            {

                if (total > 0 && total <= (decimal) 6.50)
                {
                    order.ShippingTotal = 1;
                    return order;
                }
                if (total <= 15 && total > 6)
                {
                    order.ShippingTotal = 2;
                    return order;
                }
                if (total <= 30 && total > 15)
                {
                    order.ShippingTotal = 3;
                    return order;
                }
                if (total <= 100 && total > 30)
                {
                    order.ShippingTotal = 5;
                    return order;
                }
                if (total <= 150 && total > 100)
                {
                    order.ShippingTotal = 12;
                    return order;
                }
                order.ShippingTotal = 15;
                return order;
            }
            if (total > 0 && total <= 15)
            {
                order.ShippingTotal = 4;
                return order;
            }
            if (total <= 30 && total > 15)
            {
                order.ShippingTotal = 7;
                return order;
            }
            if (total <= 75 && total > 30)
            {
                order.ShippingTotal = 15;
                return order;
            }
            if (total <= 150 && total > 75)
            {
                order.ShippingTotal = 20;
                return order;
            }
            order.ShippingTotal = 25;
            return order;
        }
Ejemplo n.º 30
0
        private ContactOperationStatus UpdateContact(Contact contact)
        {
            var opStatus = new ContactOperationStatus { Status = true };

            var careWebServices = new CARECustomerPortalExtensions.CareWebServices.NDataAccessSoapClient();

            //first update contact information
            string sendXML = String.Format("<Parameters>" +
                "<ContactNumber>{0}</ContactNumber>" +
                "<Title>{1}</Title>" +
                "<Forenames>{2}</Forenames>" +
                "<Surname>{3}</Surname>" +
                "<Address>{4}</Address>" +
                "<Town>{5}</Town>" +
                "<County>{6}</County>" +
                "<Country>{7}</Country>" +
                "<DirectNumber>{8}</DirectNumber>" +
                "<MobileNumber>{9}</MobileNumber>" +
                "<EmailAddress>{10}</EmailAddress>" +
                 "<UserLogname>fscweb</UserLogname>" +
                "</Parameters>",
                contact.ExternalContactNumber, contact.Title, contact.FirstName, contact.LastName, contact.Address1 + "\n" + contact.Address2 + "\n" + contact.Address3,
                contact.Town, contact.County, contact.Country, contact.Telephone, contact.Mobile, contact.Email);

            //Load xmldata into XDocument Object
            XDocument sendingXMLDoc = XDocument.Parse(sendXML);

            string returnXML = careWebServices.UpdateContact(sendingXMLDoc.ToString());

            XDocument receivingXMLDoc = XDocument.Parse(returnXML);

            try
            {
                //TODO: what to do about lack of address number returned?
                int careContactNumber = Convert.ToInt32(receivingXMLDoc.Element("Result")
                    .Element("ContactNumber").Value);
                contact.ExternalContactNumber = careContactNumber;
                opStatus.Contact = contact;
                opStatus.Message = "The contact has been successfully updated.";
            }
            catch (Exception e)
            {
                opStatus = OperationStatusExceptionHelper<ContactOperationStatus>
                    .CreateFromException("Error updating contact in CARE: " + e.Message, e);
                opStatus.Status = false;

            }
            //if update of contact information worked
            //* if (opStatus.Status)
            //{
            //update address information
            //    sendXML = String.Format("<Parameters>" +
            //        "<ContactNumber>{0}</ContactNumber>" +
            //        "<AddressNumber>{1}</AddressNumber>" +
            //        "<Address>{2}</Address>" +
            //        "<Town>{3}</Town>" +
            //        "<County>{4}</County>" +
            //       "<Country>{5}</Country>" +
            //      contact.ExternalContactNumber, contact.ExternalAddressNumber, contact.Address1 + "\n" + contact.Address2 + "\n" + contact.Address3,
            //       contact.Town, contact.County, contact.Country);

            //Load xmldata into XDocument Object
            //              sendingXMLDoc = XDocument.Parse(sendXML);
            //
            //returnXML = careWebServices.UpdateAddress(sendingXMLDoc.ToString());
            //            receivingXMLDoc = XDocument.Parse(returnXML);
            //try
            //{
            //     int careAddressNumber = Convert.ToInt32(receivingXMLDoc.Element("Result")
            //         .Element("AddressNumber").Value);
            //}
            //catch (Exception e)
            //{
            //    opStatus = ContactOperationStatus.CreateFromException("Error updating address in CARE: " + e.Message, e);
            //    opStatus.Status = false;

            //}
            //}
            return opStatus;
        }