public DateTime AddDate(Recurring habit_, DateTime occurence)
        {
            switch (habit_.frequency)
            {
            case "Hours":
                return(occurence.AddHours(habit_.how_common));

            case "Days":
                return(occurence.AddDays(habit_.how_common));

            case "Weeks":
                return(occurence.AddDays(7 * habit_.how_common));

            case "Months":
                return(occurence.AddMonths(Convert.ToInt32(habit_.how_common)));

            case "Default":
                //
                return(occurence.AddDays(1));

            case "One Time":
                //
                return(occurence.AddDays(1));
            }
            // to prevent an infinite recursion loop
            return(occurence.AddDays(1));
        }
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public override List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (Recurring != null)
            {
                p.Add(new KeyValuePair <string, string>("Recurring", Recurring.ToString()));
            }

            if (TriggerBy != null)
            {
                p.Add(new KeyValuePair <string, string>("TriggerBy", TriggerBy.ToString()));
            }

            if (UsageCategory != null)
            {
                p.Add(new KeyValuePair <string, string>("UsageCategory", UsageCategory.ToString()));
            }

            if (PageSize != null)
            {
                p.Add(new KeyValuePair <string, string>("PageSize", PageSize.ToString()));
            }

            return(p);
        }
Пример #3
0
        private string AskCustomerCharge(string shop, string token)
        {
            //create charged
            var recurring = new Recurring();

            recurring.Charge = new ChargeDetails
            {
                Name      = "Fulfillment App Pro",
                Price     = "20.00",
                ReturnUrl = string.Format("https://{0}/fulfillment/chargeresult?shop={1}", appUrl, shop),
                TrialDays = "2",
                Test      = "true"
            };

            var chargeResultDetails = CreateCharged(token, shop, recurring);

            if (chargeResultDetails.StatusCode == HttpStatusCode.Created)
            {
                ChargeResult chargeResult = JsonConvert.DeserializeObject <ChargeResult>(chargeResultDetails.Content);

                //save to DB


                //send to charge link for customer to accept or declined charge

                return(chargeResult.recurring_application_charge.confirmation_url);
            }
            return("");
        }
    private SeriesTimerInfo GetSeriesTimerInfo(Recurring i)
    {
        var info = new SeriesTimerInfo
        {
            ChannelId          = i.ChannelId.ToString(CultureInfo.InvariantCulture),
            Id                 = i.Id.ToString(CultureInfo.InvariantCulture),
            StartDate          = DateTimeOffset.FromUnixTimeSeconds(i.StartTimeTicks).DateTime,
            EndDate            = DateTimeOffset.FromUnixTimeSeconds(i.EndTimeTicks).DateTime,
            PrePaddingSeconds  = i.PrePadding * 60,
            PostPaddingSeconds = i.PostPadding * 60,
            Name               = i.Name ?? i.EpgTitle,
            RecordNewOnly      = i.OnlyNewEpisodes
        };

        if (info.ChannelId == "0")
        {
            info.RecordAnyChannel = true;
        }

        if (i.Days == null)
        {
            info.RecordAnyTime = true;
        }
        else
        {
            info.Days = (i.Days ?? string.Empty).Split(':')
                        .Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d.Trim(), true))
                        .ToList();
        }

        return(info);
    }
 public habit_data_modification(Recurring habit)
 {
     habit_data_ = null;
     InitializeComponent();
     data_entry          = new DataSubmissions.Base_Data_Entry(habit);
     maincontent.Content = data_entry.Content;
 }
Пример #6
0
 public override void setup_around_habit(Recurring habit)
 {
     habit_ = habit;
     end_date_picker.Date = habit_.date_ended;
     freq_.let_data(habit_.how_common, habit_.frequency);
     freq_2.let_data(habit_.how_common_2, habit_.frequency_2);
 }
Пример #7
0
 public Sale(string salesAgent, string client, int clientId, double saleAmount, Recurring recurring, int timeFrame)
 {
     SalesAgent        = salesAgent;
     Client            = client;
     ClientId          = clientId;
     SaleAmount        = saleAmount;
     Recurring         = recurring;
     TimeFrameInMonths = timeFrame;
 }
Пример #8
0
 public Sale(string salesPerson, string client, int clientId, int salesTotal, Recurring recurring, string timeframe)
 {
     SalesPerson = salesPerson;
     Client      = client;
     ClientId    = clientId;
     SalesTotal  = salesTotal;
     Recurring   = recurring;
     TimeFrame   = timeframe;
 }
        public Recurring GetHabit()
        {
            double money_saved_2 = 0.0;

            double.TryParse(moneySaved.Text, out money_saved_2);
            double money_saved_1 = 0.0;

            double.TryParse(moneySaved2.Text, out money_saved_1);

            double how_common_1 = child_form.how_common_1();
            double how_common_2 = child_form.how_common_2();

            string frequency_1 = child_form.frequency_1();
            string frequency_2 = child_form.frequency_2();
            double savings     = new utils_data.FrequencyTranslator().get_savings(
                money_saved_1, frequency_1, how_common_1,
                money_saved_2, frequency_2, how_common_2
                );
            Recurring Habit_;
            DateTime  date_ended = child_form.end_date();

            if (habit_ != null)
            {
                habit_.Name          = nameEntry.Text;
                habit_.date_started  = child_form.get_start_date();
                habit_.money_saved   = savings;
                habit_.date_ended    = child_form.get_end_date();
                habit_.how_common    = child_form.how_common_1();
                habit_.frequency     = child_form.frequency_1();
                habit_.Type          = child_form.type();
                habit_.frequency_2   = child_form.frequency_2();
                habit_.how_common_2  = child_form.how_common_2();
                habit_.money_saved_1 = money_saved_1;
                habit_.money_saved_2 = money_saved_2;

                Habit_ = habit_;
            }
            else
            {
                Habit_ = new Recurring
                {
                    Name          = nameEntry.Text,
                    date_started  = child_form.get_start_date(),
                    money_saved   = savings,
                    date_ended    = child_form.get_end_date(),
                    how_common    = child_form.how_common_1(),
                    frequency     = child_form.frequency_1(),
                    Type          = child_form.type(),
                    frequency_2   = child_form.frequency_2(),
                    how_common_2  = child_form.how_common_2(),
                    money_saved_1 = money_saved_1,
                    money_saved_2 = money_saved_2,
                };
                Habit_.stash_to_use = App.Database.GetStashesID(stash_id);
            }
            return(Habit_);
        }
 public void set_habit(Recurring habit)
 {
     habit_ = habit;
     radiogroupcontrollers[habit.Type].IsChecked = true;
     child_form.let_habit(habit);
     moneySaved.Text  = Convert.ToString(habit.money_saved_2);
     moneySaved2.Text = Convert.ToString(habit.money_saved_1);
     nameEntry.Text   = habit.Name;
 }
Пример #11
0
 public bool CreateRecurring(Recurring instance)
 {
     if (instance.id == 0)
     {
         Db.Recurrings.Add(instance);
         Db.SaveChanges();
         return(true);
     }
     return(false);
 }
        async void OnButtonClicked(object sender, EventArgs e)
        {
            Recurring Habit_ = this.GetHabit();
            int       job_id = await App.Database.SaveItemAsync(Habit_);

            this.save_Habit_Data(Habit_);

            parent_.refresh();
            this.refresh();
        }
Пример #13
0
        public bool UpdateRecurring(Recurring instance)
        {
            var cache = Db.Recurrings.FirstOrDefault(o => o.id == instance.id);

            if (cache != null)
            {
                Db.Entry(cache).CurrentValues.SetValues(instance);
                Db.SaveChanges();
                return(true);
            }
            return(false);
        }
Пример #14
0
        /// <summary>
        /// Efetua o preenchimento comum aos métodos de Recorrente
        /// </summary>
        private void FillRecurringBase(String merchantId, String merchantKey, String referenceNum, decimal chargeTotal
                                       , String processorId, String numberOfInstallments, String chargeInterest
                                       , String ipAddress, String action, String startDate
                                       , String frequency, String period, String installments, String failureThreshold
                                       , String currencyCode)
        {
            this.request = new TransactionRequest(merchantId, merchantKey);

            Order       order            = this.request.Order;
            RequestBase recurringPayment = new RequestBase();

            order.RecurringPayment = recurringPayment;

            recurringPayment.ReferenceNum = referenceNum;
            recurringPayment.ProcessorId  = processorId;
            recurringPayment.IpAddress    = ipAddress;

            Payment payment = new Payment();

            recurringPayment.Payment = payment;
            payment.ChargeTotal      = chargeTotal;
            payment.CurrencyCode     = currencyCode;

            if (String.IsNullOrEmpty(numberOfInstallments))
            {
                numberOfInstallments = "0";
            }

            int tranInstallments = int.Parse(numberOfInstallments);

            //Verifica se vai precisar criar o nó de parcelas e juros.
            if (!String.IsNullOrEmpty(chargeInterest) && tranInstallments > 1)
            {
                payment.CreditInstallment = new CreditInstallment();
                payment.CreditInstallment.ChargeInterest       = chargeInterest.ToUpper();
                payment.CreditInstallment.NumberOfInstallments = numberOfInstallments;
            }

            Recurring recurring = new Recurring();

            recurringPayment.Recurring = recurring;

            recurring.Action           = action;
            recurring.FailureThreshold = failureThreshold;
            recurring.Frequency        = frequency;
            recurring.Installments     = installments;
            recurring.Period           = period;
            recurring.StartDate        = startDate;
        }
Пример #15
0
        public void ProcessRecurring()
        {
            TaskExceptionList taskExceptionList = new TaskExceptionList();

            Console.WriteLine("{0} MyWorkbench Recurring - Recurring started Successfuly!", DateTime.Now.ToString());

            using (Recurring recurring = new Recurring(Config.ConnectionString))
            {
                taskExceptionList = recurring.Process();
            }

            if (taskExceptionList.TaskExceptions.Count >= 1)
            {
                throw new Exception(taskExceptionList.ToString());
            }
        }
        protected bool deleteRelated(DataAction action, Recurring changedEvent, DHXSchedulerModelsDataContext context)
        {
            bool finished = false;

            if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type))
            {
                context.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev);
            }
            if (action.Type == DataActionTypes.Delete && (changedEvent.event_pid != 0 && changedEvent.event_pid != null))
            {
                Recurring changed = (from ev in context.Recurrings where ev.id == action.TargetId select ev).Single();
                changed.rec_type = "none";
                finished         = true;
            }
            return(finished);
        }
Пример #17
0
        public IRestResponse CreateCharged(string token, string shop, Recurring recurring)
        {
            var client = new RestClient("https://" + shop + "/admin/");

            var request = new RestRequest("recurring_application_charges.json", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddHeader("X-Shopify-Access-Token", token);
            string json = JsonConvert.SerializeObject(recurring, Formatting.Indented);

            request.AddParameter("application/json", json, ParameterType.RequestBody);

            // execute the request
            var result = client.Execute(request);

            return(result);
        }
        protected bool deleteRelated(DataAction action, Recurring changedEvent)
        {
            bool finished = false;

            if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type))
            {
                Repository.RemoveRecurringCondition(Repository.Recurrings.Where(ev => ev.event_pid == changedEvent.id));
                //Repository.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev);
            }
            if (action.Type == DataActionTypes.Delete && (changedEvent.event_pid != 0 && changedEvent.event_pid != null))
            {
                Recurring changed = Repository.Recurrings.First(ev => ev.id == action.TargetId);
                //(from ev in context.Recurrings where ev.id == action.TargetId select ev).Single();
                changed.rec_type = "none";
                finished         = true;
            }
            return(finished);
        }
        public void CreateRecurringTest()
        {
            Recurring rec =
                new Recurring
                    {
                        ClientId = ClientTest.SampleClient().ClientId,
                        PoNumber = "1234",
                        Lines = new LineItems
                        {
                            LineList =
                                {
                                    new LineItem
                                        {
                                            Name = "Widget 1.0a (revision 3B)",
                                            Description = "A widget for the whatsit",
                                            UnitCost = 22.44,
                                            Quantity = 100,
                                        },
                                    new LineItem
                                        {
                                            Name = "Monarch 2",
                                            Description = "A pretty little butterfly",
                                            UnitCost = 123.56,
                                            Quantity = 1,
                                        }
                                }
                        }
                    };

            RecurringIdentity id = Service.Create(new RecurringRequest {Recurring = rec,});

            try
            {
                Recurring fetched = Service.Get(id).Recurring;
                Assert.AreEqual("1234", fetched.PoNumber);
                Assert.AreEqual(2367.56, fetched.Amount);
                Assert.AreEqual(2, fetched.Lines.LineList.Count);
            }
            finally
            {
                Service.Delete(id);
            }
        }
Пример #20
0
        /// <summary>
        /// Validates if recurring entity contains the required information.
        /// </summary>
        /// <param name="entity">object</param>
        /// <param name="fields">list</param>
        /// <param name="silent">boold</param>
        /// <returns>bool</returns>
        public bool IsValid(object entity, out List <string> fields, bool silent)
        {
            List <string> errors    = new List <string>();
            Recurring     recurring = (Recurring)entity;

            if (!PERIODS.Contains(recurring.Periodicity))
            {
                errors.Add("periodicity");
            }

            if (!IsInteger(recurring.Interval.ToString()))
            {
                errors.Add("interval");
            }

            if (recurring.NextPayment == null || !IsActualDate(recurring.NextPayment))
            {
                errors.Add("nextPayment");
            }

            if (!IsInteger(recurring.MaxPeriods.ToString()))
            {
                errors.Add("maxPeriods");
            }

            if (recurring.DueDate != null && !IsActualDate(recurring.DueDate))
            {
                errors.Add("dueDate");
            }

            if (errors?.Any() ?? false)
            {
                fields = errors;
                ThrowValidationException(errors, "Recurring", silent);

                return(false);
            }

            fields = null;

            return(true);
        }
        private SeriesTimerInfo GetSeriesTimerInfo(Recurring i)
        {
            var info = new SeriesTimerInfo();

            try
            {
                info.ChannelId = i.channelID.ToString();

                info.Id = i.id.ToString(_usCulture);

                info.StartDate = DateTimeOffset.FromUnixTimeSeconds(i.startTimeTicks).DateTime;
                info.EndDate   = DateTimeOffset.FromUnixTimeSeconds(i.endTimeTicks).DateTime;

                info.PrePaddingSeconds  = i.prePadding * 60;
                info.PostPaddingSeconds = i.postPadding * 60;

                info.Name          = i.name ?? i.epgTitle;
                info.RecordNewOnly = i.onlyNewEpisodes;
                if (info.ChannelId == "0")
                {
                    info.RecordAnyChannel = true;
                }

                if (i.days == null)
                {
                    info.RecordAnyTime = true;
                }
                else
                {
                    info.Days = (i.days ?? string.Empty).Split(':')
                                .Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d.Trim(), true))
                                .ToList();
                }

                return(info);
            }
            catch (Exception err)
            {
                throw (err);
            }
        }
Пример #22
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (CallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.ToString()));
            }

            if (TriggerValue != null)
            {
                p.Add(new KeyValuePair <string, string>("TriggerValue", TriggerValue));
            }

            if (UsageCategory != null)
            {
                p.Add(new KeyValuePair <string, string>("UsageCategory", UsageCategory.ToString()));
            }

            if (CallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString()));
            }

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (Recurring != null)
            {
                p.Add(new KeyValuePair <string, string>("Recurring", Recurring.ToString()));
            }

            if (TriggerBy != null)
            {
                p.Add(new KeyValuePair <string, string>("TriggerBy", TriggerBy.ToString()));
            }

            return(p);
        }
        /// <summary>
        /// Set recurring property data.
        /// </summary>
        /// <param name="data">object</param>
        /// <returns>object</returns>
        public object SetRecurring(object data)
        {
            if (data != null)
            {
                if (data.GetType() == typeof(JObject))
                {
                    data = new Recurring((JObject)data);
                }

                if (!(data.GetType() == typeof(Recurring)))
                {
                    data = null;
                }
            }

            PropertyInfo propertyInfo = GetType().GetProperty(RECURRING_PROPERTY);

            propertyInfo.SetValue(this, data);

            return(this);
        }
Пример #24
0
        internal void DoCustomBinding()
        {
            if (ScheduleType != ScheduleTypeEnum.Recurring)
            {
                Recurring = RecurringSchedule.Empty;
            }
            else
            {
                Recurring.DoCustomBinding();
            }

            if (ScheduleType != ScheduleTypeEnum.OneTimeEvent)
            {
                StartDate = ScheduleHelper.DefaultStartDate;
                EndDate   = ScheduleHelper.DefaultEndDate;
            }
            else
            {
                if (StartRightNow || StartDate < DateTime.Now)
                {
                    StartDate = DateTime.Now.AddSeconds(10);
                }

                if (WithoutEndDate)
                {
                    EndDate = ArticleScheduleConstants.Infinity;
                }
            }

            if (StartRightNow && WithoutEndDate)
            {
                ScheduleType = ScheduleTypeEnum.Visible;
            }

            if (Article.Delayed)
            {
                StartDate = PublicationDate;
                EndDate   = ArticleScheduleConstants.Infinity;
            }
        }
Пример #25
0
        static void Main(string[] args)
        {
            //Creating Some employees to start with
            var Jim = new SalesEmployee();

            Jim.EmployeeName = "Jim Halpert";
            var Dwight = new SalesEmployee();

            Dwight.EmployeeName = "Dwight Schrute";
            var Phyllis = new SalesEmployee {
                EmployeeName = "Phyllis Leaf"
            };
            var Benji = new SalesEmployee {
                EmployeeName = "Benji Palmer"
            };
            var Oscar = new AccountingEmployee();

            Oscar.EmployeeName = "Oscar";
            var Kevin = new AccountingEmployee();

            Kevin.EmployeeName = "Kevin";
            var Holly = new SalesEmployee {
                EmployeeName = "Holly Flax"
            };

            //Making lists of the sales employees and accountants
            var SalesEmployees = new List <SalesEmployee>
            {
                Jim,
                Dwight,
                Phyllis,
                Holly,
                Benji,
            };

            var Accountants = new List <AccountingEmployee>
            {
                Oscar,
                Kevin
            };

            //Making some sales to work with
            var dummySale1 = new Sale(Phyllis.EmployeeName, "Taco Hell", 2433, 52000, Recurring.Annually, "5 months");
            var dummySale2 = new Sale(Dwight.EmployeeName, "Bed, Math and Beyond", 0444, 29340, Recurring.Monthly, "10 months");
            var dummySale3 = new Sale(Jim.EmployeeName, "Catalina Wine Mixer", 4444, 125000, Recurring.Annually, "1 month");
            var dummySale4 = new Sale(Phyllis.EmployeeName, "Vance Refridgeration", 5252, 44500, Recurring.Weekly, "1 month");
            var dummySale5 = new Sale(Holly.EmployeeName, "Wal-Bart", 123, 4525, Recurring.Monthly, "1 month");
            var dummySale6 = new Sale(Benji.EmployeeName, "Not Target", 456, 4, Recurring.Annually, "2 month");

            Holly.SalesDictionary.Add(dummySale5.ClientId, dummySale5);
            Benji.SalesDictionary.Add(dummySale6.ClientId, dummySale6);
            Phyllis.SalesDictionary.Add(dummySale1.ClientId, dummySale1);
            Phyllis.SalesDictionary.Add(dummySale4.ClientId, dummySale4);
            Dwight.SalesDictionary.Add(dummySale2.ClientId, dummySale2);
            Jim.SalesDictionary.Add(dummySale3.ClientId, dummySale3);


            //Making some offices and adding employees to the offices
            var scrantonOffice = new Office("Scranton Office");
            var nashuaOffice   = new Office("Nashua Office");

            scrantonOffice.OfficeEmployees.Add(Jim);
            scrantonOffice.OfficeEmployees.Add(Dwight);
            scrantonOffice.OfficeEmployees.Add(Phyllis);

            nashuaOffice.OfficeEmployees.Add(Benji);
            nashuaOffice.OfficeEmployees.Add(Holly);

            var listOfOffices = new List <Office> {
                scrantonOffice, nashuaOffice
            };


            var initialSelection = "";
            var chosenOffice     = new Office("holder");

            do
            {
                //Office Selection Menu
BeginningOfOfficeChoice:
                //Console.WriteLine(@"
                //        1. Choose an Office.
                //        2. Create a new Office.");
                AnsiConsole.MarkupLine(@"
                           [bold yellow on purple]1.Choose an Office.[/]
                           [bold purple on yellow]2.Create a new Office.[/]");
                var officeSelection = Console.ReadLine();


                //First switch statement handles the Office choice/creation
                switch (officeSelection)
                {
                case "1":
                    var counter = 1;

                    foreach (var office in listOfOffices)
                    {
                        Console.WriteLine($"{counter}. {office.Name}");
                        counter++;
                    }

                    var officeInput = Console.ReadLine();
                    chosenOffice = listOfOffices[(Int32.Parse(officeInput) - 1)];

                    Console.Clear();
                    Console.WriteLine($"You chose {chosenOffice.Name}");
                    break;

                case "2":
                    Console.WriteLine("Please enter new Office name:");
                    var newOfficeName = Console.ReadLine();
                    var newOffice     = new Office(newOfficeName);
                    listOfOffices.Add(newOffice);
                    Console.Clear();
                    Console.WriteLine($"Thanks for adding {newOfficeName}");
                    goto BeginningOfOfficeChoice;

                default:
                    Console.WriteLine("Invalid Entry. Press 1 or 2.");
                    goto BeginningOfOfficeChoice;
                }

                //Main Menu --------------------------------------------------
BeginningOfMainMenu:
                AnsiConsole.MarkupLine($@"
                        [underline purple]Welcome to Dufflin/Munder Cardboard Co. [/]
                        [underline purple]Sales Portal![/]

                        [bold yellow]1.Enter Sales[/]
                        [bold red]2.Generate Report For Accountant[/]
                        [bold green]3.Add New Sales Employee[/]
                        [bold yellow]4.Find a Sale[/]
                        [bold red]5.Generate A Report for whole Office[/]
                        [bold green]6.Go To Office Menu[/]
                        [bold #FFC0CB]7.Exit[/]
                       [bold #FFFFFF] ------------------[/]");

                initialSelection = Console.ReadLine();
                switch (initialSelection)
                {
                case "1":
                    Console.Clear();

                    //This adds all sales to a master list so we can validate if the clientId already exists later in the form
                    var dictionaryOfAllSales = new Dictionary <int, Sale>();
                    foreach (var employee in SalesEmployees)
                    {
                        foreach (var sale in employee.SalesDictionary)
                        {
                            dictionaryOfAllSales.Add(sale.Key, sale.Value);
                        }
                    }


                    Console.WriteLine("Which person are you?");

                    var counter = 1;

                    foreach (var employee in SalesEmployees)
                    {
                        Console.WriteLine($"{counter}. {employee.EmployeeName}");
                        counter++;
                    }

                    var employeeInput  = Console.ReadLine();
                    var chosenEmployee = SalesEmployees[(Int32.Parse(employeeInput) - 1)];

                    Console.Clear();

                    Console.WriteLine($"Hi, {chosenEmployee.EmployeeName}!! ");
                    Console.WriteLine();
                    Console.WriteLine($"Sales Agent: {chosenEmployee.EmployeeName} ");

                    Console.Write("Client: ");
                    string clientName = Console.ReadLine();


enterNewClientId:
                    Console.Write("ClientId: ");
                    var clientId = Console.ReadLine();

                    if (dictionaryOfAllSales.ContainsKey(Int32.Parse(clientId)))
                    {
                        Console.WriteLine("Client Id already exists");
                        goto enterNewClientId;
                    }

                    Console.Write("Sale: $");
                    var salesTotal = Console.ReadLine();

                    //This validates if it is a valid Enum, if its not it will go to the else and run again
StartOfRecurring:
                    Console.Write("Recurring (ex: Monthly, Annually, Quarterly): ");
                    var       recurringAmount = Console.ReadLine();
                    Recurring passedInput     = Recurring.None;
                    if (Enum.IsDefined(typeof(Recurring), recurringAmount))
                    {
                        passedInput = (Recurring)Enum.Parse(typeof(Recurring), recurringAmount);
                    }
                    else
                    {
                        Console.WriteLine("Incorrect Input! Try Monthly, Annually, Quarterly, or Weekly.");
                        goto StartOfRecurring;
                    }

                    Console.Write("Time Frame: ");
                    var timeFrame = Console.ReadLine();

                    chosenEmployee.SalesDictionary.Add(Int32.Parse(clientId), new Sale(chosenEmployee.EmployeeName, clientName, Int32.Parse(clientId), Int32.Parse(salesTotal), passedInput, timeFrame));

                    Console.Clear();
                    Console.WriteLine($"Sale Input Recieved! Good work {chosenEmployee.EmployeeName}");


                    goto BeginningOfMainMenu;

                case "2":
                    Console.Clear();

                    Console.WriteLine("Which accountant are you?");
                    var accountantCounter = 1;
                    foreach (var employee in Accountants)
                    {
                        Console.WriteLine($"{accountantCounter}. {employee.EmployeeName}");
                        accountantCounter++;
                    }
                    var userInput          = Console.ReadLine();
                    var selectedAccountant = Accountants[(Int32.Parse(userInput) - 1)];
                    Console.Clear();


                    Console.WriteLine($"Monthly Sales Report For: {selectedAccountant.EmployeeName}");
                    Console.WriteLine();
                    foreach (var employee in SalesEmployees)
                    {
                        Console.WriteLine($"    {employee.EmployeeName}");
                        var total = 0;
                        Console.WriteLine(@"        Clients:");
                        foreach (var(Key, Value) in employee.SalesDictionary)
                        {
                            Console.WriteLine($"        {Value.Client}");
                            total += Value.SalesTotal;
                        }
                        Console.WriteLine($"    Total: ${total}");
                        Console.WriteLine();
                    }
                    goto BeginningOfMainMenu;

                case "3":
                    //Adds the employee
                    Console.Clear();
                    Console.WriteLine("Please enter new saleperson's name:");
                    var newSalesperson = Console.ReadLine();
                    var newPerson      = new SalesEmployee {
                        EmployeeName = newSalesperson
                    };
                    SalesEmployees.Add(newPerson);

                    //Adds the employee to the office
                    Console.WriteLine("Which Office do they belong to?");
                    var OfficeCounter = 1;
                    foreach (var office in listOfOffices)
                    {
                        Console.WriteLine($"{OfficeCounter}. {office.Name}");
                        OfficeCounter++;
                    }

                    var officeInput = Console.ReadLine();
                    chosenOffice = listOfOffices[(Int32.Parse(officeInput) - 1)];
                    chosenOffice.OfficeEmployees.Add(newPerson);

                    Console.Clear();
                    goto BeginningOfMainMenu;

                case "4":
                    Console.Clear();
                    Console.WriteLine("Please enter the client ID number:");
                    var clientNumber = Console.ReadLine();
                    var dictionaryOfAllOfTheSales = new Dictionary <int, Sale>();
                    foreach (var employee in SalesEmployees)
                    {
                        foreach (var sale in employee.SalesDictionary)
                        {
                            dictionaryOfAllOfTheSales.Add(sale.Key, sale.Value);
                        }
                    }
                    Console.Clear();
                    Console.WriteLine($"ClientId: {dictionaryOfAllOfTheSales[Int32.Parse(clientNumber)].ClientId}");
                    Console.WriteLine($"Client: {dictionaryOfAllOfTheSales[Int32.Parse(clientNumber)].Client}");
                    Console.WriteLine($"Salesperson: {dictionaryOfAllOfTheSales[Int32.Parse(clientNumber)].SalesPerson}");
                    Console.WriteLine($"Sales Total: ${dictionaryOfAllOfTheSales[Int32.Parse(clientNumber)].SalesTotal}");
                    Console.WriteLine($"Recurring: {dictionaryOfAllOfTheSales[Int32.Parse(clientNumber)].Recurring}");
                    Console.WriteLine($"Timeframe: {dictionaryOfAllOfTheSales[Int32.Parse(clientNumber)].TimeFrame}");
                    goto BeginningOfMainMenu;

                case "5":
                    Console.WriteLine($"Monthly Sales Report For: {chosenOffice.Name}");
                    Console.WriteLine();
                    foreach (var employee in chosenOffice.OfficeEmployees)
                    {
                        Console.WriteLine($"    {employee.EmployeeName}");
                        var total = 0;
                        Console.WriteLine(@"        Clients:");
                        foreach (var(Key, Value) in employee.SalesDictionary)
                        {
                            Console.WriteLine($"        {Value.Client}");
                            total += Value.SalesTotal;
                        }
                        Console.WriteLine($"    Total: ${total}");
                        Console.WriteLine();
                    }
                    goto BeginningOfMainMenu;

                case "6":
                    goto BeginningOfOfficeChoice;

                default:
                    Console.WriteLine($"Thank you for visiting {chosenOffice.Name}");
                    break;
                }
            } while (initialSelection != "7");
        }
 public async void save_Habit_Data(Recurring Habit_)
 {
     App.Database.save_habit_data(Habit_);
 }
Пример #27
0
        public static void EnterASale()
        {
            Console.Clear();
            // User entry for sales employee selection
            var salesAgent        = "";
            int employeeSelection = 0;

            Console.WriteLine("Which sales employee are you?");

            for (var i = 0; i < Company.SalesEmployees.Count; i++)
            {
                Console.WriteLine($"{i + 1}. {Company.SalesEmployees[i].Name}");
            }
            var selection = Console.ReadLine();

            try
            {
                employeeSelection = Convert.ToInt32(selection);
                salesAgent        = Company.SalesEmployees[employeeSelection - 1].Name;
            }
            catch (FormatException)
            {
                string employeeName = selection;
                if (Company.SalesEmployees.Any(employee => employee.Name.ToLower() == employeeName.ToLower()))
                {
                    salesAgent = char.ToUpper(employeeName[0]) + employeeName.Substring(1);
                }
                else
                {
                    Console.WriteLine($"Please enter a number 1-{Company.SalesEmployees.Count()} to select an employee. Please return to the main menu and try again.\n");
                    Program.BackToStart();
                }
            }

            Console.Clear();
            Console.WriteLine($"Hi, {salesAgent}.\n");

            // Enter a Sale method begins
            Console.WriteLine("Enter a Sale\n");

            // Sales agent is automatically generated from previous selection
            Console.WriteLine($"Sales Agent: {salesAgent}");

            // User entry for client name
            Console.Write("Client: ");
            var client   = Console.ReadLine();
            var random   = new Random();
            var clientId = random.Next(1000, 9999);

            foreach (var employee in Company.SalesEmployees)
            {
                foreach (var completedSale in employee.AllSales)
                {
                    if (completedSale.Client.ToLower() == client.ToLower())
                    {
                        clientId = completedSale.ClientId;
                    }
                }
            }

            Console.WriteLine($"ClientID: {clientId}");

            // User entry for sale amount
            Console.Write("Sale: $");
            double saleAmount = 0.0;

            try
            {
                saleAmount = Convert.ToDouble(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine($"Please enter a number for the sale amount. Please return to the main menu and try again.\n");
                Program.BackToStart();
            }

            // User entry for recurring value
            Console.Write("Recurring (Monthly, Annually, or One-Time): ");
            var recurringInput = Console.ReadLine().ToLower();

            Recurring recurring = Recurring.OneTime;

            if (recurringInput != "monthly" && recurringInput != "annually" && recurringInput != "one-time")
            {
                Console.Write("Please enter a valid recurring value: ");
                recurringInput = Console.ReadLine().ToLower();
            }

            if (recurringInput == "monthly" || recurringInput == "annually" || recurringInput == "one-time")
            {
                switch (recurringInput)
                {
                case "monthly":
                    recurring = Recurring.Monthly;
                    break;

                case "annually":
                    recurring = Recurring.Annually;
                    break;

                case "one-time":
                    recurring = Recurring.OneTime;
                    break;

                default:
                    break;
                }
            }
            else
            {
                Console.WriteLine("You did not enter a valid value. Please return to the main menu and try again.\n");
                Program.BackToStart();
            }

            // User entry for time frame
            Console.Write("Time Frame (in months): ");
            int timeFrame = 0;

            try
            {
                timeFrame = Convert.ToInt32(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine($"Please enter a number of months for the time frame. Please return to the main menu and try again.\n");
                Program.BackToStart();
            }

            // Add the sale to that employee class and return to main menu
            var sale            = new Sale(salesAgent, client, clientId, saleAmount, recurring, timeFrame);
            var currentEmployee = Company.SalesEmployees.Find(employee => employee.Name == salesAgent);

            currentEmployee.AddSale(sale);

            Console.WriteLine($"\nYour sale was added!\n");

            Program.BackToStart();
        }
 public void let_habit(Recurring habit)
 {
     habit_          = habit;
     start_date.Date = habit.date_started;
     this.setup_around_habit(habit);
 }
 public virtual void setup_around_habit(Recurring habit)
 {
 }
Пример #30
0
 public TransactionDetails() {
     this.recurringField = Recurring.No;
     this.taxExemptField = TaxExempt.No;
     this.transactionOriginField = TransactionDetailsTransactionOrigin.ECI;
 }
Пример #31
0
        public void PaymentRequestXmlSettersTest()
        {
            Card card = new Card();

            card.ExpiryDate     = sx.CARD_EXPIRY_DATE;
            card.Number         = sx.CARD_NUMBER;
            card.Type           = CardType.VISA;
            card.CardHolderName = sx.CARD_HOLDER_NAME;
            card.IssueNumber    = sx.CARD_ISSUE_NUMBER;

            Cvn cvn = new Cvn();

            cvn.Number            = sx.CARD_CVN_NUMBER;
            cvn.PresenceIndicator = sx.CARD_CVN_PRESENCE;
            card.Cvn = cvn;

            PaymentRequest request = new PaymentRequest();

            request.Account    = sx.ACCOUNT;
            request.MerchantId = sx.MERCHANT_ID;
            request.Type       = PaymentType.AUTH;

            RxpAmount amount = new RxpAmount();

            amount.Amount   = sx.AMOUNT;
            amount.Currency = sx.CURRENCY;
            request.Amount  = amount;

            AutoSettle autoSettle = new AutoSettle();

            autoSettle.Flag = sx.AUTO_SETTLE_FLAG;

            request.AutoSettle = autoSettle;
            request.Card       = card;
            request.Timestamp  = sx.TIMESTAMP;
            request.Channel    = sx.CHANNEL;
            request.OrderId    = sx.ORDER_ID;
            request.Hash       = sx.REQUEST_HASH;

            List <RxpComment> comments = new List <RxpComment>();
            RxpComment        comment  = new RxpComment();

            comment.Id      = 1;
            comment.Comment = sx.COMMENT1;
            comments.Add(comment);
            comment         = new RxpComment();
            comment.Id      = 2;
            comment.Comment = sx.COMMENT2;
            comments.Add(comment);
            request.Comments = comments;

            request.PaymentsReference = sx.PASREF;
            request.AuthCode          = sx.AUTH_CODE;
            request.RefundHash        = sx.REFUND_HASH;
            request.FraudFilter       = sx.FRAUD_FILTER;

            Recurring recurring = new Recurring();

            recurring.Flag     = sx.RECURRING_FLAG;
            recurring.Sequence = sx.RECURRING_SEQUENCE;
            recurring.Type     = sx.RECURRING_TYPE;
            request.Recurring  = recurring;

            TssInfo tssInfo = new TssInfo();

            tssInfo.CustomerNumber    = sx.CUSTOMER_NUMBER;
            tssInfo.ProductId         = sx.PRODUCT_ID;
            tssInfo.VariableReference = sx.VARIABLE_REFERENCE;
            tssInfo.CustomerIpAddress = sx.CUSTOMER_IP;

            List <Address> addresses = new List <Address>();
            Address        address   = new Address();

            address.Type    = sx.ADDRESS_TYPE_BUSINESS;
            address.Code    = sx.ADDRESS_CODE_BUSINESS;
            address.Country = sx.ADDRESS_COUNTRY_BUSINESS;
            addresses.Add(address);

            address         = new Address();
            address.Type    = sx.ADDRESS_TYPE_SHIPPING;
            address.Code    = sx.ADDRESS_CODE_SHIPPING;
            address.Country = sx.ADDRESS_COUNTRY_SHIPPING;
            addresses.Add(address);

            tssInfo.Addresses = addresses;
            request.TssInfo   = tssInfo;

            Mpi mpi = new Mpi();

            mpi.Cavv    = sx.THREE_D_SECURE_CAVV;
            mpi.Xid     = sx.THREE_D_SECURE_XID;
            mpi.Eci     = sx.THREE_D_SECURE_ECI;
            request.Mpi = mpi;

            //convert to XML
            string xml = request.ToXml();

            //Convert from XML back to PaymentRequest
            PaymentRequest fromXmlRequest = new PaymentRequest().FromXml(xml);

            sx.checkUnmarshalledPaymentRequest(fromXmlRequest);
        }
 public IActionResult SendMail(int userId, string message)
 {
     Recurring.Job();
     return(Ok("Job çalıştı"));
 }