Exemple #1
0
        public void SendEmail(TestVM model)
        {
            if (ModelState.IsValid && !string.IsNullOrEmpty(model.EmailToSend) && !string.IsNullOrEmpty(model.Name))
            {
                string body = "";


                #region Generate random string (result in result variable)

                // var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                //var random = new Random();
                var result = "";// new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray());

                #endregion

                SiteDT siteDT = SitesManager.GetSite(model.SiteID);
                using (CastleClubEntities entities = new CastleClubEntities())
                {
                    Customer customer = entities.Customers.Where(c => c.Email == model.EmailToSend && c.SiteId == siteDT.Id).FirstOrDefault();
                    if (customer != null)
                    {
                        result = customer.UnEncryptPass;

                        if (result == null)
                        {
                            var chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                            var random = new Random();
                            result = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray());

                            Password p = new Password(result);
                            customer.Password      = p.SaltedPassword;
                            customer.UnEncryptPass = p.ClearPassword;
                            //customer.
                            customer.SaltKey = p.SaltKey;

                            entities.SaveChanges();
                        }
                    }
                }
                body = string.Format(Email.WelcomeBodyEmail(), model.Name,
                                     model.EmailToSend, result, siteDT.Name, siteDT.Name, "PartsGeek",
                                     siteDT.Price, siteDT.PricePerQuarter, siteDT.Phone, siteDT.Email, siteDT.OfferDomain);

                string subject = string.Format(Email.WelcomeSubjectEmail(), siteDT.Name);
                CastleClub.BusinessLogic.Utils.Email.SendEmailWithBCC(siteDT.Email, siteDT.PasswordEmail, siteDT.SmtpAddress, subject, body
                                                                      , new List <string>()
                {
                    model.EmailToSend
                }, new List <string>()
                {
                    siteDT.WelcomeEmailBCC
                }, true);
            }
        }
Exemple #2
0
        public ActionResult PreviewEmail(int ID)
        {
            var model = new PreviewEmailVM();
            //int ID = 14;
            SiteDT siteDT = SitesManager.GetSite(ID);
            string name   = "Alexander Broderick";
            string email  = "*****@*****.**";
            var    chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var    random = new Random();
            var    result = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray());

            model.HtmlEmail = string.Format(Email.WelcomeBodyEmail(), name,
                                            email, result, siteDT.Name, siteDT.Name, "PartsGeek",
                                            siteDT.Price, siteDT.PricePerQuarter, siteDT.Phone, siteDT.Email, siteDT.OfferDomain);
            return(View(model));
        }
Exemple #3
0
        public ActionResult ActivateAllActiveCustomers()
        {
            AccessVM model = new AccessVM();

            using (CastleClubEntities entities = new CastleClubEntities())
            {
                //SiteDT site = entities.Sites.Where(s=> s.Active == true).ToList().Select(s => s.GetDT()).FirstOrDefault();
                //var today = DateTime.Today.AddDays(-2);
                SiteDT site = SitesManager.GetSite(3);
                // List<CustomerDT> customers = entities.Customers.Where(c => c.StatusId == "ACTIVE" && c.SiteId == site.Id).ToList().Select(c => c.GetDT(false)).ToList();
                List <CustomerDT> customers = entities.Customers.Where(c => c.SiteId == site.Id).ToList().Select(c => c.GetDT(false)).ToList();
                //List<CustomerDT> customers = entities.Customers.ToList().Select(c => c.GetDT(false)).ToList();

                /*List<int> idList = new List<int>()
                 * {
                 * };*/
                string customerAutoPriceDiscount = "";
                foreach (CustomerDT custom in customers)
                {
                    try
                    {
                        /*if (idList.Contains(custom.Id) && custom.Status == DataTypes.Enums.CustomerStatus.ACTIVE)
                         * {
                         *    //string response = CustomersManager.NewActivateMember(SitesManager.GetSite(custom.SiteId), custom, "CLOSED");
                         *    string response = CustomersManager.NewActivateMember(SitesManager.GetSite(custom.SiteId), custom, "OPEN");
                         * }
                         * else
                         * if (idList.Contains(custom.Id) && custom.Status != DataTypes.Enums.CustomerStatus.ACTIVE)
                         * {
                         *  string response = CustomersManager.NewActivateMember(SitesManager.GetSite(custom.SiteId), custom, "SUSPEND");
                         *  customerAutoPriceDiscount +=  custom.Id.ToString() + " \n ,";
                         * }
                         */
                    }
                    catch (Exception e)
                    {
                    }

                    // RootObject oMyclass = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(response);
                }
                return(View(model));
            }
        }
Exemple #4
0
        private static void SendEmail(int SiteID, CustomerDT Customer, string ClearPassword)
        {
            SiteDT siteDT = SitesManager.GetSite(SiteID);
            string body   = string.Format(Email.WelcomeBodyEmail(), Customer.FirstName,
                                          Customer.Email, ClearPassword, siteDT.Name, siteDT.Name, "PartsGeek",
                                          siteDT.Price, siteDT.PricePerQuarter, siteDT.Phone, siteDT.Email, siteDT.OfferDomain);

            string subject = string.Format(Email.WelcomeSubjectEmail(), siteDT.Name);

            /**/
            CastleClub.BusinessLogic.Utils.Email.SendEmailWithBCC(siteDT.Email, siteDT.PasswordEmail, siteDT.SmtpAddress, subject, body
                                                                  , new List <string>()
            {
                Customer.Email
            }, new List <string>()
            {
                siteDT.WelcomeEmailBCC
            }, true);
            /**/
        }
Exemple #5
0
        /// <summary>
        /// Resume all transaction of range. Successfull and Fail
        /// </summary>
        /// <param name="siteID">0 for all site.</param>
        /// <param name="from">From date</param>
        /// <param name="to">To date</param>
        /// <returns>Index 0 is successfull, and index 1 is fail.</returns>
        public static decimal[] TransactionReport(int siteID, DateTime from, DateTime to)
        {
            using (CastleClubEntities entities = new CastleClubEntities())
            {
                decimal[] resp = new decimal[2];
                resp[0] = 0;
                resp[1] = 0;

                if (siteID == 0)
                {
                    var sites = SitesManager.GetSites();
                    foreach (var site in sites)
                    {
                        GetTransactionReportFromAuthorizeForSite(site, from, to.Date.AddDays(1).AddSeconds(-1), resp, entities);
                    }
                }
                else
                {
                    GetTransactionReportFromAuthorizeForSite(SitesManager.GetSite(siteID), from, to.Date.AddDays(1).AddSeconds(-1), resp, entities);
                }

                return(resp);
            }
        }
Exemple #6
0
        public ActionResult SalesReport(SalesReportVM model)
        {
            if (!ModelState.IsValid)
            {
                model.Referrers = SitesManager.GetReferrers();
                model.Sites     = SitesManager.GetSites();
                return(View(model));
            }

            List <KeyValuePair <string, List <ReferrerSalesInfoDT> > > data = new List <KeyValuePair <string, List <ReferrerSalesInfoDT> > >();

            if (model.ReferrerId != 0)
            {
                if (model.SiteId != 0)
                {
                    ReferrerDT referrer = SitesManager.GetReferrer(model.ReferrerId);
                    List <ReferrerSalesInfoDT> referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), model.ReferrerId, model.SiteId);
                    data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >(referrer.Name + " - " + SitesManager.GetSite(model.SiteId).Name, referrerData));
                }
                else
                {
                    ReferrerDT referrer = SitesManager.GetReferrer(model.ReferrerId);
                    List <ReferrerSalesInfoDT> referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), model.ReferrerId, model.SiteId);
                    data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >(referrer.Name + " - All Sites", referrerData));

                    foreach (var site in SitesManager.GetSites())
                    {
                        referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), model.ReferrerId, site.Id);
                        data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >(referrer.Name + " - " + site.Name, referrerData));
                    }
                }
            }
            else
            {
                if (model.SiteId != 0)
                {
                    string sitenName = SitesManager.GetSite(model.SiteId).Name;
                    List <ReferrerSalesInfoDT> referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), 0, model.SiteId);
                    data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >("All Websites - " + sitenName, referrerData));

                    foreach (ReferrerDT referrer in SitesManager.GetReferrers())
                    {
                        referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), referrer.Id, model.SiteId);
                        data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >(referrer.Name + " - " + sitenName, referrerData));
                    }
                }
                else
                {
                    List <ReferrerSalesInfoDT> referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), 0, model.SiteId);
                    data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >("All Websites - All Sites", referrerData));

                    foreach (var site in SitesManager.GetSites())
                    {
                        foreach (ReferrerDT referrer in SitesManager.GetReferrers())
                        {
                            referrerData = SitesManager.GetReferrerSiteSalesInfo(model.StartDate, model.EndDate, (DateGroupBy)Enum.Parse(typeof(DateGroupBy), model.GroupBy), referrer.Id, site.Id);
                            data.Add(new KeyValuePair <string, List <ReferrerSalesInfoDT> >(referrer.Name + " - " + site.Name, referrerData));
                        }
                    }
                }
            }
            ViewBag.Data = data;

            model.Referrers = SitesManager.GetReferrers();
            model.Sites     = SitesManager.GetSites();
            return(View(model));
        }
Exemple #7
0
        public ActionResult Chart(ChartReportVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            List <ReportData> list     = new List <ReportData>(4);
            string            siteName = model.SiteID == 0 ? "All web sites" : SitesManager.GetSite(model.SiteID).Name;

            #region
            var data = new ReportData();

            data.Colors = new List <string>();
            data.Colors.Add("#00FF00");
            data.Colors.Add("#FF0000");
            data.Colors.Add("#0000FF");

            data.Type               = "column";
            data.YAxisTitle         = "Values (USD)";
            data.TooltipValueSuffix = "USD";
            data.Text               = "The last four " + CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.AddDays(-1).DayOfWeek).ToLower() + " (" + siteName + ")";

            var reportDay = SitesManager.GetSiteReportTheLastFourDay(model.SiteID);

            data.Categories = new List <string>();
            foreach (var item in reportDay)
            {
                data.Categories.Add(item.Key.ToString("MM-dd-yyyy"));
            }

            data.Series = new List <Data>();

            Data revenueDay = new Data()
            {
                name = "Revenue", data = new List <double>()
            };
            foreach (var item in reportDay)
            {
                revenueDay.data.Add(item.Value[0]);
            }
            Data costDay = new Data()
            {
                name = "Cost", data = new List <double>()
            };
            foreach (var item in reportDay)
            {
                costDay.data.Add(item.Value[1]);
            }
            Data profitDay = new Data()
            {
                name = "Profit", data = new List <double>()
            };
            foreach (var item in reportDay)
            {
                profitDay.data.Add(item.Value[0] - item.Value[1]);
            }

            data.Series.Add(revenueDay);
            data.Series.Add(costDay);
            data.Series.Add(profitDay);
            data.Id = Guid.NewGuid().ToString();

            #region Table

            data.Table      = new ChartTable();
            data.Table.Cols = new List <string>();
            data.Table.Rows = new List <string>();
            data.Table.Data = new string[reportDay.Count][];

            data.Table.Rows.Add("Revenue");
            data.Table.Rows.Add("Cost");
            data.Table.Rows.Add("Profit");

            int index = 0;
            foreach (var item in reportDay)
            {
                data.Table.Cols.Add(item.Key.ToString("MM/dd/yyyy"));

                data.Table.Data[index]    = new string[3];
                data.Table.Data[index][0] = item.Value[0].ToString();
                data.Table.Data[index][1] = item.Value[1].ToString();
                data.Table.Data[index][2] = (item.Value[0] - item.Value[1]).ToString();

                index = index + 1;
            }

            #endregion

            list.Add(data);
            #endregion

            #region
            var data2 = new ReportData();

            data2.Colors = new List <string>();
            data2.Colors.Add("#00FF00");
            data2.Colors.Add("#FF0000");
            data2.Colors.Add("#0000FF");

            data2.Text               = "The last four months" + " (" + siteName + ")";
            data2.Type               = "column";
            data2.YAxisTitle         = "Values (USD)";
            data2.TooltipValueSuffix = "USD";
            var reportMonth = SitesManager.GetSiteReportTheLastFourMonth(model.SiteID);

            data2.Categories = new List <string>();
            foreach (var item in reportMonth)
            {
                data2.Categories.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(item.Key.Month) + " " + item.Key.Year);
            }

            data2.Series = new List <Data>();

            Data revenueMonth = new Data()
            {
                name = "Revenue", data = new List <double>()
            };
            foreach (var item in reportMonth)
            {
                revenueMonth.data.Add(item.Value[0]);
            }
            Data costMonth = new Data()
            {
                name = "Cost", data = new List <double>()
            };
            foreach (var item in reportMonth)
            {
                costMonth.data.Add(item.Value[1]);
            }
            Data profitMonth = new Data()
            {
                name = "Profit", data = new List <double>()
            };
            foreach (var item in reportMonth)
            {
                profitMonth.data.Add(item.Value[0] - item.Value[1]);
            }

            data2.Series.Add(revenueMonth);
            data2.Series.Add(costMonth);
            data2.Series.Add(profitMonth);
            data2.Id = Guid.NewGuid().ToString();

            #region Table

            data2.Table      = new ChartTable();
            data2.Table.Cols = new List <string>();
            data2.Table.Rows = new List <string>();
            data2.Table.Data = new string[reportMonth.Count][];

            data2.Table.Rows.Add("Revenue");
            data2.Table.Rows.Add("Cost");
            data2.Table.Rows.Add("Profit");

            index = 0;
            foreach (var item in reportMonth)
            {
                data2.Table.Cols.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(item.Key.Month) + " " + item.Key.Year);

                data2.Table.Data[index]    = new string[3];
                data2.Table.Data[index][0] = item.Value[0].ToString();
                data2.Table.Data[index][1] = item.Value[1].ToString();
                data2.Table.Data[index][2] = (item.Value[0] - item.Value[1]).ToString();

                index = index + 1;
            }

            #endregion

            list.Add(data2);
            #endregion

            #region
            var data3 = new ReportData();

            data3.Colors = new List <string>();
            data3.Colors.Add("#00FF00");
            data3.Colors.Add("#FF0000");
            data3.Colors.Add("#0000FF");

            data3.Text               = "The last fifteen days" + " (" + siteName + ")";
            data3.Type               = "column";
            data3.YAxisTitle         = "Values (USD)";
            data3.TooltipValueSuffix = "USD";
            var reportFifteenDays = SitesManager.GetSiteReportTheLastFifteenDays(model.SiteID);

            data3.Categories = new List <string>();
            foreach (var item in reportFifteenDays)
            {
                data3.Categories.Add(item.Key.ToString("MM-dd-yyyy"));
            }

            data3.Series = new List <Data>();

            Data revenueFifteenDays = new Data()
            {
                name = "Revenue", data = new List <double>()
            };
            foreach (var item in reportFifteenDays)
            {
                revenueFifteenDays.data.Add(item.Value[0]);
            }
            Data costFifteenDays = new Data()
            {
                name = "Cost", data = new List <double>()
            };
            foreach (var item in reportFifteenDays)
            {
                costFifteenDays.data.Add(item.Value[1]);
            }
            Data profitFifteenDays = new Data()
            {
                name = "Profit", data = new List <double>()
            };
            foreach (var item in reportFifteenDays)
            {
                profitFifteenDays.data.Add(item.Value[0] - item.Value[1]);
            }

            data3.Series.Add(revenueFifteenDays);
            data3.Series.Add(costFifteenDays);
            data3.Series.Add(profitFifteenDays);
            data3.Id = Guid.NewGuid().ToString();

            #region Table

            data3.Table      = new ChartTable();
            data3.Table.Cols = new List <string>();
            data3.Table.Rows = new List <string>();
            data3.Table.Data = new string[reportFifteenDays.Count][];

            data3.Table.Rows.Add("Revenue");
            data3.Table.Rows.Add("Cost");
            data3.Table.Rows.Add("Profit");

            index = 0;
            foreach (var item in reportFifteenDays)
            {
                data3.Table.Cols.Add(item.Key.ToString("MM-dd-yyyy"));

                data3.Table.Data[index]    = new string[3];
                data3.Table.Data[index][0] = item.Value[0].ToString();
                data3.Table.Data[index][1] = item.Value[1].ToString();
                data3.Table.Data[index][2] = (item.Value[0] - item.Value[1]).ToString();

                index = index + 1;
            }

            #endregion

            list.Add(data3);
            #endregion


            #region
            var data4 = new ReportData();

            data4.Colors = new List <string>();
            data4.Colors.Add("#00FF00");
            data4.Colors.Add("#FF0000");
            data4.Colors.Add("#0000FF");

            data4.Text               = "The last sixty days" + " (" + siteName + ")";
            data4.Type               = "line";
            data4.YAxisTitle         = "Values";
            data4.TooltipValueSuffix = "";
            var reportSixtyDays = SitesManager.GetSiteReportTheLastSixtyDays(model.SiteID);

            data4.Categories = new List <string>();
            foreach (var item in reportSixtyDays)
            {
                data4.Categories.Add(item.Key.ToString("MM-dd-yyyy"));
            }

            data4.Series = new List <Data>();

            Data signupsSixtyDays = new Data()
            {
                name = "Sign Up", data = new List <double>()
            };
            foreach (var item in reportSixtyDays)
            {
                signupsSixtyDays.data.Add(item.Value[0]);
            }
            Data visitsSixtyDays = new Data()
            {
                name = "Billeds", data = new List <double>()
            };
            foreach (var item in reportSixtyDays)
            {
                visitsSixtyDays.data.Add(item.Value[1]);
            }
            Data cancellationsSixtyDays = new Data()
            {
                name = "Cancellations", data = new List <double>()
            };
            foreach (var item in reportSixtyDays)
            {
                cancellationsSixtyDays.data.Add(item.Value[2]);
            }

            data4.Series.Add(signupsSixtyDays);
            data4.Series.Add(visitsSixtyDays);
            data4.Series.Add(cancellationsSixtyDays);
            data4.Id = Guid.NewGuid().ToString();

            #region Table

            data4.Table = new ChartTable();
            /**/
            data4.Table.Cols = new List <string>();
            data4.Table.Rows = new List <string>();

            /**
             * data4.Table.Data = new string[reportSixtyDays.Count][];
             *
             *
             * data4.Table.Rows.Add("Sign Ups");
             * data4.Table.Rows.Add("Billeds");
             * data4.Table.Rows.Add("Cancellations");
             *
             * index = 0;
             * foreach (var item in reportSixtyDays)
             * {
             * data4.Table.Cols.Add(item.Key.ToString("MM-dd-yyyy"));
             *
             * data4.Table.Data[index] = new string[3];
             * data4.Table.Data[index][0] = item.Value[0].ToString();
             * data4.Table.Data[index][1] = item.Value[1].ToString();
             * data4.Table.Data[index][2] = item.Value[2].ToString();
             *
             * index = index + 1;
             * }
             **/
            data4.Table.Data = new string[3][];
            data4.Table.Cols.Add("Sign Ups");
            data4.Table.Cols.Add("Billeds");
            data4.Table.Cols.Add("Cancellations");

            data4.Table.Data[0] = new string[reportSixtyDays.Count];
            data4.Table.Data[1] = new string[reportSixtyDays.Count];
            data4.Table.Data[2] = new string[reportSixtyDays.Count];
            index = 0;
            foreach (var item in reportSixtyDays)
            {
                data4.Table.Rows.Add(item.Key.ToString("MM-dd-yyyy"));

                //data4.Table.Data[index] = new string[3];
                data4.Table.Data[0][index] = item.Value[0].ToString();
                data4.Table.Data[1][index] = item.Value[1].ToString();
                data4.Table.Data[2][index] = item.Value[2].ToString();

                index = index + 1;
            }

            #endregion

            list.Add(data4);
            #endregion


            return(Json(list));
        }