Ejemplo n.º 1
0
        public JsonNetResult RemoveSalesLeadLabel(int index)
        {
            var response = new ApplicationLeadsService.DataAccessResponseType();
            var applicationLeadsServiceClient = new ApplicationLeadsService.ApplicationLeadsServiceClient();

            var authCookie     = AuthenticationCookieManager.GetAuthenticationCookie();
            var accountNameKey = authCookie.AccountNameKey;
            var userId         = authCookie.Id.ToString();

            var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey);
            var label           = accountSettings.SalesSettings.LeadLabels[index];

            try
            {
                applicationLeadsServiceClient.Open();
                response = applicationLeadsServiceClient.RemoveLabel(accountNameKey, label,
                                                                     userId,
                                                                     ApplicationLeadsService.RequesterType.AccountUser, Common.SharedClientKey);

                //Close the connection
                WCFManager.CloseConnection(applicationLeadsServiceClient);
            }
            catch (Exception e)
            {
                #region Manage Exception

                string exceptionMessage = e.Message.ToString();

                var    currentMethod       = System.Reflection.MethodBase.GetCurrentMethod();
                string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name;

                // Abort the connection & manage the exception
                WCFManager.CloseConnection(applicationLeadsServiceClient, exceptionMessage, currentMethodString);

                // Upate the response object
                response.isSuccess    = false;
                response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage;
                //response.ErrorMessages[0] = exceptionMessage;

                #endregion
            }

            JsonNetResult jsonNetResult = new JsonNetResult();
            jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = response;

            return(jsonNetResult);
        }
        public JsonNetResult RemoveSalesAlertEmail(int index)
        {
            var accountNameKey = AuthenticationCookieManager.GetAuthenticationCookie().AccountNameKey;

            var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey);

            //Make updates:
            accountSettings.SalesSettings.AlertEmails.RemoveAt(index);

            var response = AccountSettings.UpdateAccountSettings_Internal(accountNameKey, accountSettings);

            JsonNetResult jsonNetResult = new JsonNetResult();

            jsonNetResult.Formatting = Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = response;

            return(jsonNetResult);
        }
        public JsonNetResult UpdateShowAddress(bool showAddress)
        {
            var accountNameKey = AuthenticationCookieManager.GetAuthenticationCookie().AccountNameKey;

            var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey);

            //Make updates:
            accountSettings.ContactSettings.ShowAddress = showAddress;

            var response = AccountSettings.UpdateAccountSettings_Internal(accountNameKey, accountSettings);

            JsonNetResult jsonNetResult = new JsonNetResult();

            jsonNetResult.Formatting = Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = response;

            return(jsonNetResult);
        }
        public JsonNetResult UpdateUseSalesLeads(bool useSalesLeads)
        {
            var accountNameKey = AuthenticationCookieManager.GetAuthenticationCookie().AccountNameKey;

            #region Make sure account plan allow for sales leads

            var account = Common.GetAccountObject(accountNameKey);

            if (useSalesLeads == true && account.PaymentPlan.AllowSalesLeads == false)
            {
                JsonNetResult jsonNetResultRestricted = new JsonNetResult();
                jsonNetResultRestricted.Formatting = Formatting.Indented;
                jsonNetResultRestricted.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
                jsonNetResultRestricted.Data = new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Account plan does not allow for sales leads"
                };

                return(jsonNetResultRestricted);
            }

            #endregion

            var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey);

            //Make updates:
            accountSettings.SalesSettings.UseSalesLeads = useSalesLeads;
            if (!useSalesLeads)
            {
                accountSettings.SalesSettings.UseSalesAlerts = useSalesLeads;
            }

            var response = AccountSettings.UpdateAccountSettings_Internal(accountNameKey, accountSettings);

            JsonNetResult jsonNetResult = new JsonNetResult();
            jsonNetResult.Formatting = Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = response;

            return(jsonNetResult);
        }
        public JsonNetResult UpdateCustomDomain(string customDomain)
        {
            var accountNameKey = AuthenticationCookieManager.GetAuthenticationCookie().AccountNameKey;

            var account = Common.GetAccountObject(accountNameKey);

            var response = new DataAccessResponseType();

            var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey);

            //Make updates:
            accountSettings.CustomDomain = customDomain;

            response = AccountSettings.UpdateAccountSettings_Internal(accountNameKey, accountSettings);

            JsonNetResult jsonNetResult = new JsonNetResult();

            jsonNetResult.Formatting = Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = response;

            return(jsonNetResult);
        }
        public JsonNetResult AddSalesAlertEmail(string email)
        {
            var accountNameKey = AuthenticationCookieManager.GetAuthenticationCookie().AccountNameKey;

            #region Make sure account plan allow for sales leads

            var account = Common.GetAccountObject(accountNameKey);

            if (account.PaymentPlan.AllowSalesLeads == false)
            {
                JsonNetResult jsonNetResultRestricted = new JsonNetResult();
                jsonNetResultRestricted.Formatting = Formatting.Indented;
                jsonNetResultRestricted.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
                jsonNetResultRestricted.Data = new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Account plan does not allow for sales leads"
                };

                return(jsonNetResultRestricted);
            }

            #endregion

            var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey);

            if (!email.Contains('@') || !email.Contains('.'))
            {
                JsonNetResult jsonNetResultError = new JsonNetResult();
                jsonNetResultError.Formatting = Formatting.Indented;
                jsonNetResultError.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
                jsonNetResultError.Data = new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Please use a valid email address"
                };

                return(jsonNetResultError);
            }

            //Make updates:
            if (accountSettings.SalesSettings.AlertEmails == null)
            {
                accountSettings.SalesSettings.AlertEmails = new List <string>();
            }

            if (accountSettings.SalesSettings.AlertEmails.Count >= 15)
            {
                JsonNetResult jsonNetResultError2 = new JsonNetResult();
                jsonNetResultError2.Formatting = Formatting.Indented;
                jsonNetResultError2.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
                jsonNetResultError2.Data = new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "You've reached the limit of 15 alert emails"
                };

                return(jsonNetResultError2);
            }

            foreach (string emailTest in accountSettings.SalesSettings.AlertEmails)
            {
                if (emailTest == email)
                {
                    JsonNetResult jsonNetResultError3 = new JsonNetResult();
                    jsonNetResultError3.Formatting = Formatting.Indented;
                    jsonNetResultError3.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
                    jsonNetResultError3.Data = new DataAccessResponseType {
                        isSuccess = false, ErrorMessage = "This email is already on the alert list"
                    };

                    return(jsonNetResultError3);
                }
            }


            accountSettings.SalesSettings.AlertEmails.Add(email);

            var response = AccountSettings.UpdateAccountSettings_Internal(accountNameKey, accountSettings);

            JsonNetResult jsonNetResult = new JsonNetResult();
            jsonNetResult.Formatting = Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = response;

            return(jsonNetResult);
        }