<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public class TarriffModel
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public decimal PricePerUnit { get; set; }

    }
}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Common.ISubscriptionsServices
{
    public interface ISubscriptionServices
    {
        void MakeSubscription(Subscriptions subcription);

        List<Subscriptions> GetAllSubscription();

        List<Subscriptions> GetCustomerSubscription(string customerId);

        Subscriptions FindSubscription(string customerId);

        void CancelSubcription(string id);

        List<Subscriptions> CheckActiveSubscription(string customerId);

        string UpdateSubscription(Subscriptions modifiedSubscription);
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace EDSCustomerPortal.Services.IServices
{
    public interface IAuthenticationService
    {
        string RegisterUser(CustomerModel model);

        CustomerModel GetCustomerByEmail(string email);

        CustomerModel GetCustomerById(string customerId);

        string RegisterSubscription(ElectricityTariffPayment electricityTariffPayment);

        ElectricityTariffPayment ViewCustomerSubscriptionByMeterNumber(string meterNumber);

        void DeleteSubscription(string metreId);
    }
}
<file_sep>﻿using EDSCustomerPortal.Menu;
using System;

namespace EDSCustomerPortal
{
    class Program
    {
        static void Main(string[] args)
        {
            MenuNav menuNav = new MenuNav();
            menuNav.PageMenu();
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.AgentServices.IServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.AgentServices
{
    public class AgentServices : AgentServicesAPI, IAgentServices
    {
        public string RegisterAgent(AgentsModel agent)
        {
            if (agent == null)
            {
                throw new ArgumentNullException(nameof(agent));
            }
            //This will Handle registration of an Agent
            else
            {
                fileService.Database.Agents.Add(agent);

                fileService.SaveChanges();
                return agent.Id == null ? "Failed" : "Success";
            }
        }

        public AgentsModel GetAgentById(string agentId)
        {
            AgentsModel foundAgent = fileService.Database.Agents.Find(c => c.Id == agentId);

            if (foundAgent != null)
            {
                return foundAgent;
            }
            return null;
        }

        //Find Agent via Email
        public AgentsModel GetAgentByEmail(string email)
        {
            AgentsModel foundAgentEmail = fileService.Database.Agents.Find(c => c.EmailAddress == email);
            if (foundAgentEmail != null)
            {
                return foundAgentEmail;
            }
            return null;
        }

        public string UpdateAgent(AgentsModel modifiedAgent)
        {

            AgentsModel foundAgent = this.GetAgentById(modifiedAgent.Id);
            if (foundAgent != null)
            {
                //fileService.Database.Customers.IndexOf(foundCustomer);
                //fileService.Database.Customers.Insert(indexOfFoundCustomer, foundCustomer);
                fileService.SaveChanges();
                return "SUCCESS";
            }

            return "FAILURE NOT FOUND";
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EDSAgentPortal.Validation
{
    public class Security
    {
        public static string ReadPassword(char mask)
        {
            const int ENTER = 13, BACKSP = 8, CTRLBACKSP = 127;
            int[] FILTERED = { 0, 27, 9, 10 /*, 32 space, if you care */ }; // const

            var pass = new Stack<char>();
            char chr = (char)0;

            while ((chr = System.Console.ReadKey(true).KeyChar) != ENTER)
            {
                if (chr == BACKSP)
                {
                    if (pass.Count > 0)
                    {
                        System.Console.Write("\b \b");
                        pass.Pop();
                    }
                }
                else if (chr == CTRLBACKSP)
                {
                    while (pass.Count > 0)
                    {
                        System.Console.Write("\b \b");
                        pass.Pop();
                    }
                }
                else if (FILTERED.Count(x => chr == x) > 0) { }
                else
                {
                    pass.Push((char)chr);
                    System.Console.Write(mask);
                }
            }

            System.Console.WriteLine();

            return new string(pass.Reverse().ToArray());
        }
        public static string ReadPassword()
        {
            return ReadPassword('*');
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public class Subscriptions
    {
        public string Id { get; set; }
        public decimal Amount { get; set; }
        public string TariffId { get; set; }
        public string CustomerId { get; set; }
        public string AgentId { get; set; }
        public DateTime SubcriptionDateTime { get; set; } = DateTime.Now;
        public string SubscriptionStatus { get; set; }

    }
}
<file_sep>﻿using EDSAgentPortal.AgentMenu;
using ElectricityDigitalSystem.Common;
using ElectricityDigitalSystem.Common.ISubscriptionsServices;
using System;

namespace EDSAgentPortal
{
    class Program
    {
        static void Main(string[] args)
        {
            ITariffServices tariffServices = new TariffServices();
            tariffServices.AddTariffToService();

            AgentMenuNav agentMenuNav = new AgentMenuNav();
            agentMenuNav.PageMenuNav();
        }
    }
}
<file_sep>﻿using EDSAgentPortal.AgentMenu.AgentLogInMenu;
using EDSAgentPortal.Validation;
using ElectricityDigitalSystem.AgentServices;
using ElectricityDigitalSystem.AgentServices.IServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSAgentPortal.AgentMenu
{
    public class AgentMenu
    {

        readonly IAgentServices agentServices = new AgentServices();

        readonly AgentMenuNav agentMenuNav = new AgentMenuNav();

        readonly ValidationClass validation = new ValidationClass();

        readonly LogInMenuNav loginMenuNav = new LogInMenuNav();

        public void RegisterAgent()
        {
            Dictionary<string, string> navItemDIc = new Dictionary<string, string>();
            List<string> navigationItems = new List<string>
            {
                "FirstName", "LastName", "Email", "Password", "PhoneNumber"
            };
            Console.Clear();
            Console.WriteLine("Please Provide your Details : ");

            for (int i = 0; i < navigationItems.Count; i++)
            {
                Console.Write($"Enter your {navigationItems[i]} : ");
                var value = Console.ReadLine();

                while (string.IsNullOrEmpty(value))
                {
                    Console.WriteLine($"{navigationItems[i]} cannot be left blank");
                    Console.Write($"{navigationItems[i]} : ");
                    value = Console.ReadLine();
                }

                navItemDIc.Add(navigationItems[i], value);
            }

            string FirstName, LastName, Email, Password, PhoneNumber;
            FirstName = navItemDIc["FirstName"];
            LastName = navItemDIc["LastName"];
            Email = navItemDIc["Email"];
            Password = navItemDIc["Password"];
            PhoneNumber = navItemDIc["PhoneNumber"];

            ulong number = validation.CheckPhoneNumber(PhoneNumber);
            
            AgentsModel model = new AgentsModel
            {
                FirstName = FirstName,
                LastName = LastName,
                EmailAddress = Email,
                Password = <PASSWORD>,
                PhoneNumber = number.ToString("00000000000"),
            };

            string registrationResponds = agentServices.RegisterAgent(model);
            if (registrationResponds == "Success")
            {
                Console.WriteLine();
                Console.WriteLine("Registration Successful");
                Console.WriteLine("Redirecting you to Home Page....");
                Thread.Sleep(3000);
            }
            else
                Console.WriteLine("An Error occured While Trying to Create your Account Please try Again");

            agentMenuNav.PageMenuNav();
           
        }

        public void LoginAgent()
        {
            string Email, Password;

            Console.Clear();
            Console.WriteLine("Please Login with your Email and Password");
            Console.Write($"Please Enter your Email : ");
            Email = Console.ReadLine();
            Console.Write($"Please Enter your Password : ");
            Password = <PASSWORD>();

            var agent = agentServices.GetAgentByEmail(Email);
            
            if (agent == null)
            {
                Console.WriteLine("No Email Found");
                Thread.Sleep(3000);

                agentMenuNav.PageMenuNav();
            }
            else
            {
                if (agent.Password != <PASSWORD>)
                {
                    Console.WriteLine("Invalid Login Credentials \nPlease Create an Account!");
                    Thread.Sleep(3000);

                    agentMenuNav.PageMenuNav();
                }
                else
                {
                    //call the loginPageNav
                    loginMenuNav.LogInPageMenuNav(agent.Id, agent.FirstName, agent.LastName);

                }
            }
        }
    }
}

<file_sep># Team-Saturn-ElectricityDigitalSystem

Team Project Done by Ekene, Sarah and Michael and supervised by Soji

Problem : 
The government of Nigeria wants to make power Generation and Management / Distribution easy for its citizens. Previously , Customers had to Go Directly to the offices of the discos ( distribution companies) to refill their Bill. But now The Government wants that process to become easy. For this reason they have come to Your team to come up with a solution.

Using The Pillars Of Object Oriented Programming learned over the past few weeks, write a software program That the Disco Company Agents can Use To 

Register a New Customer Into the System/ Remove a Customer From the System / Update a Customer’s information
Accept And Process Payments from a Customer For a particular Electricity Tariff subscription and Store that Information on the Customer in their Database
View the Personal/ Electricity  Tariff Information related to a Customer. 
Modify the Information for an Electrify Power Tariff Plan(i.e Price per Units of Electricity)

Also, 
Write another  simple Software Program That the Customer can Use To
Register into the System.
Subscribe for an Electricity Tariff
Unsubscribe from an Electricity Tariff 
Update personal Information

Notes :

When A Customer has Subscribed for an electricity tariff, it should reflect in the Agents Application Database.


Hints
Use a persistent storage type (most likely Text file or Json File) as your database
Create a Library and Two Console Applications (one for the agent and one for the customer) 
The Two Console Applications  should be serviced from the common Library. Ie (add a reference to the Library project inside both console apps)
The Library should be smart enough to separate namespaces that are only peculiar to the Customer application or to the Agent Application.
-Only the Library should be able to read/write to the database. The service layers can also stay inside the Library project (as namespaces)
Your program should be interactive.
When you want to run your program, to run the customer app, just change your starting point to the program.cs file of the customer console app,
Alternatively when you want to run the Agent Application, change your starting point to the Program.cs file for  the Agent app
<file_sep>﻿using EDSAgentPortal.Validation;
using ElectricityDigitalSystem.AgentServices;
using ElectricityDigitalSystem.AgentServices.IServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSAgentPortal.AgentMenu.AgentLogInMenu.CustomerPortfolio
{
    public class CustomerPortMenu
    {
        readonly IAgentCustomerServices agentCustomerServices = new AgentCustomerServices();

        readonly ValidationClass validation = new ValidationClass();

        readonly CustomerPortMenuNav customerPortMenuNav = new CustomerPortMenuNav();

        public void RegisterCustomer(string registeringAgent)
        {
            Dictionary<string, string> navItemDIc = new Dictionary<string, string>();
            List<string> navigationItems = new List<string>
            {
                "FirstName", "LastName", "Email", "Password", "PhoneNumber"
            };
            Console.Clear();
            Console.WriteLine("Please Provide your Details : ");

            for (int i = 0; i < navigationItems.Count; i++)
            {
                Console.Write($"Enter your {navigationItems[i]} : ");
                var value = Console.ReadLine();

                while (string.IsNullOrEmpty(value))
                {
                    Console.WriteLine($"{navigationItems[i]} cannot be left blank");
                    Console.Write($"{navigationItems[i]} : ");
                    value = Console.ReadLine();
                }

                navItemDIc.Add(navigationItems[i], value);
            }

            string FirstName, LastName, Email, Password, PhoneNumber;
            FirstName = navItemDIc["FirstName"];
            LastName = navItemDIc["LastName"];
            Email = navItemDIc["Email"];
            Password = navItemDIc["Password"];
            PhoneNumber = navItemDIc["PhoneNumber"];

            ulong number = validation.CheckPhoneNumber(PhoneNumber);

            CustomerModel model = new CustomerModel
            {
                FirstName = FirstName,
                LastName = LastName,
                EmailAddress = Email,
                Password = <PASSWORD>,
                PhoneNumber = number.ToString("00000000000"),
                AgentId = registeringAgent
            };

            string registrationResponds = agentCustomerServices.RegisterCustomer(model);

            if (registrationResponds == "Success")
            {
                Console.WriteLine();
                Console.WriteLine("Registration Successful");
                Console.WriteLine("Redirecting you to Home Page....");
                Thread.Sleep(3000);
                customerPortMenuNav.CustomerPortPageMenuNav(registeringAgent);
            }
            else
            {
                Console.WriteLine("An Error occured While Trying to Create your Account Please try Again");

                customerPortMenuNav.CustomerPortPageMenuNav(registeringAgent);
            }
        }

        public void ViewCustomerInfo()
        {
            string result = EmailCheck();

            if (result == "Failed")
            {
                Console.WriteLine("No Valid Email Found");
                Thread.Sleep(3000);
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine($"{"Full Name",-20} : {agentCustomerServices.GetCustomerByEmail(result).FirstName} {agentCustomerServices.GetCustomerByEmail(result).LastName}");
                Console.WriteLine($"{"Email Address",-20} : {agentCustomerServices.GetCustomerByEmail(result).EmailAddress} ");
                Console.WriteLine($"{"Phone Number",-20} : {agentCustomerServices.GetCustomerByEmail(result).PhoneNumber} ");
                Console.WriteLine($"{"Meter Number",-20} : {agentCustomerServices.GetCustomerByEmail(result).MeterNumber} ");
                Console.WriteLine($"{"Registered Agent Id",-20} : {agentCustomerServices.GetCustomerByEmail(result).AgentId} ");
                Console.WriteLine($"{"Created Date Time",-20} : {agentCustomerServices.GetCustomerByEmail(result).CreatedDateTime} ");
                Console.WriteLine($"{"Modified Date Time",-20} : {agentCustomerServices.GetCustomerByEmail(result).ModifiedDateTime} ");

                Console.ReadKey();
            }  
        }

        public void ViewAllRegisteredCustomer()
        {
            var values = agentCustomerServices.GetAllRegisteredCustomer();

            if (values == null)
            {
                Console.WriteLine("No Customer Registered!!!!");
            }
            else
            {
                foreach (var item in values)
                {
                    Console.WriteLine();
                    Console.WriteLine($"{"Full Name",-20} : {item.FirstName} {item.LastName}");
                    Console.WriteLine($"{"Email Address",-20} : {item.EmailAddress} ");
                    Console.WriteLine($"{"Phone Number",-20} : {item.PhoneNumber} ");
                    Console.WriteLine($"{"Meter Number",-20} : {item.MeterNumber} ");
                    Console.WriteLine($"{"Registered Agent Id",-20} : {item.AgentId} ");
                    Console.WriteLine($"{"Created Date Time",-20} : {item.CreatedDateTime} ");
                    Console.WriteLine($"{"Modified Date Time",-20} : {item.ModifiedDateTime} "); 
                }
                Console.ReadKey();
            }  
        }

        public void UpdatePersonalInfo()
        {
            string result = EmailCheck();

            if (result == "Failed")
            {
                Console.WriteLine("No Valid Email Found");
                Thread.Sleep(3000);
            }
            else
            {
                var customerEmail = agentCustomerServices.GetCustomerByEmail(result);

                bool inputAnother;

                do
                {
                    Console.WriteLine($"What would you like to Update?\n 1. First Name      2. Last Name        3. Email Address        4. Phone Number     5. Password");
                    string response = Console.ReadLine();

                    switch (response)
                    {
                        case "1":
                            Console.WriteLine("Please enter your new First Name :");
                            customerEmail.FirstName = Console.ReadLine();
                            customerEmail.ModifiedDateTime = DateTime.Now;
                            break;
                        case "2":
                            Console.WriteLine("Please enter your new Last Name :");
                            customerEmail.LastName = Console.ReadLine();
                            customerEmail.ModifiedDateTime = DateTime.Now;
                            break;
                        case "3":
                            Console.WriteLine("Please enter your new Email Address :");
                            customerEmail.EmailAddress = Console.ReadLine();
                            customerEmail.ModifiedDateTime = DateTime.Now;
                            break;
                        case "4":
                            Console.WriteLine("Please enter your new Phone Number :");
                            customerEmail.PhoneNumber = Console.ReadLine();
                            customerEmail.ModifiedDateTime = DateTime.Now;
                            break;
                        case "5":
                            Console.WriteLine("Please enter your new Password :");
                            customerEmail.Password = Console.ReadLine();
                            customerEmail.ModifiedDateTime = DateTime.Now;
                            break;
                    }

                    Console.WriteLine("Would you like to update another information? (Y/N)");
                    var continueEditing = Console.ReadLine();

                    if (continueEditing.ToLower() == "y")
                    {
                        inputAnother = true;
                    }
                    else
                    {
                        inputAnother = false;
                    }

                } while (inputAnother);

                agentCustomerServices.UpdateCustomer(customerEmail);

                Console.WriteLine("Successful!!!");
                Thread.Sleep(3000);
            }
        }

        private string EmailCheck()
        {
            Console.Clear();
            Console.WriteLine("Please Can I have the Email you used in Registering :");
            Console.Write("The Email Address : ");
            string email = Console.ReadLine();

            while (string.IsNullOrEmpty(email))
            {
                Console.Write("Please Enter an Email Address : ");
                email = Console.ReadLine();
            }

            var customer = agentCustomerServices.GetCustomerByEmail(email);

            if (customer == null)
            {
                return "Failed";
            }
            else
            {
                return customer.EmailAddress;
            }
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Common.ISubscriptionsServices
{
    public interface ITariffServices
    {
        void AddTariffToService();

        void PushToDb(TarriffModel model);

        List<TarriffModel> GetAllTariff();

        TarriffModel GetTarriffByName(string name);

        TarriffModel GetTarriffById(string id);
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public class CustomerModel : BaseUserModel
    {
        readonly Random meterNumber = new Random();

       public CustomerModel()
       {
           this.Id = "CUS-" + Guid.NewGuid().ToString();
           this.MeterNumber = ($"EDS-{meterNumber.Next(100000000, 999999999)}");
        }

        public string MeterNumber { get; set; }

        public string AgentId { get; set; }

        public string Password { get; set; }




    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
   public class ElectricityTariffPayment
    {
        public string MeterNumber { get; set; }

        public string TariffId { get; set; }

        public string PricePerUnit { get; set; }

        public string AmountPaid { get; set; }

        public string NumberOfUnit { get; set; }

        public DateTime DateOfPayment { get; set; } = DateTime.Now;


    }
}
<file_sep>﻿using ElectricityDigitalSystem.AgentServices;
using ElectricityDigitalSystem.AgentServices.IServices;
using ElectricityDigitalSystem.Common;
using ElectricityDigitalSystem.Common.ISubscriptionsServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSAgentPortal.AgentMenu.AgentLogInMenu.CustomerPortfolio
{
    public class AgentCustomerSubscriptions
    {
        readonly ISubscriptionServices subscriptionServices = new SubscriptionServices();

        readonly ITariffServices tariffServices = new TariffServices();

        readonly IAgentCustomerServices agentCustomerServices = new AgentCustomerServices();

        readonly CustomerPortMenuNav customerPortMenuNav = new CustomerPortMenuNav();

        decimal t1, t2, t3, t4 = default;
        string a1, a2, a3, a4 = default;

        public void CancelCustomerSubscription()
        {
            Console.Clear();
            Console.WriteLine("Would you like to cancel your active subscription?\n1 : Yes\n2 : No");
            var entry = Console.ReadLine();
            switch (entry)
            {
                case "1":
                    CancelSub();
                    break;
                case "2":
                    Console.WriteLine("Processing...");
                    Thread.Sleep(3000);
                    break;
                default:
                    CancelCustomerSubscription();
                    break;
            }
        }

        public void CancelSub()
        {
            Console.Clear();
            var userEmailCheck = EmailCheck();

            if (userEmailCheck == "Failed")
            {
                Console.WriteLine("No Valid Email Found");
                Thread.Sleep(3000);
            }
            else
            {
                var customerToBeSubscribeID = agentCustomerServices.GetCustomerByEmail(userEmailCheck).Id;
                var activeSub = subscriptionServices.CheckActiveSubscription(customerToBeSubscribeID);

                if (activeSub.Count == 0)
                {
                    Console.WriteLine("\nYou do not have an Active subscription");
                    Thread.Sleep(3000);
                }
                else
                {
                    foreach (var item in activeSub)
                    {
                        item.SubscriptionStatus = "Inactive";
                        subscriptionServices.UpdateSubscription(item);
                        Console.WriteLine("\nSubscription cancelled successfully");
                    }
                    Thread.Sleep(3000);
                }
            }
        }

        public void MakeSubscription(string registeringAgent)
        {
            Console.Clear();
            var userEmailCheck = EmailCheck();

            if (userEmailCheck == "Failed")
            {
                Console.WriteLine("No Valid Email Found");
                Thread.Sleep(3000);
            }
            else
            {
                var customerToBeSubscribeID = agentCustomerServices.GetCustomerByEmail(userEmailCheck).Id;
                var activeSub = subscriptionServices.CheckActiveSubscription(customerToBeSubscribeID);

                if (activeSub.Count != 0)
                {
                    //Show all Tariff
                    Console.WriteLine("You currently have an active subscription \nBuying a new Subscription will deactivate your previous subscription");
                    Console.WriteLine("1 : Continue \n2 : Back to Home ");
                    string entry = Console.ReadLine();

                    switch (entry)
                    {
                        case "1":
                            MakeSubscriptionPayment(registeringAgent, customerToBeSubscribeID);
                            break;
                        case "2":
                            customerPortMenuNav.CustomerPortPageMenuNav(registeringAgent);
                            break;
                        default:
                            MakeSubscription(registeringAgent);
                            break;
                    }
                }
                else
                {
                    MakeSubscriptionPayment(registeringAgent, customerToBeSubscribeID);
                }
            } 
        }

        private void MakeSubscriptionPayment(string registeringAgent, string customerToBeSubscribeID)
        {
            Console.Clear();
            var tariffs = tariffServices.GetAllTariff();
            Console.WriteLine("We have four Tariffs");
            Console.WriteLine("\nTariff Name      Tariff Price");
            for (var i = 0; i < tariffs.Count; i++)
            {
                Console.Write($"{i + 1} : {tariffs[i].Name}     #{tariffs[i].PricePerUnit} \n");
                if (i == 0)
                {
                    t1 = tariffs[i].PricePerUnit;
                    a1 = tariffs[i].Id;

                }
                else if (i == 1)
                {
                    t2 = tariffs[i].PricePerUnit;
                    a2 = tariffs[i].Id;
                }
                else if (i == 2)
                {
                    t3 = tariffs[i].PricePerUnit;
                    a3 = tariffs[i].Id;

                }
                else if (i == 3)
                {
                    t4 = tariffs[i].PricePerUnit; ;
                    a4 = tariffs[i].Id;
                }
            }
            Console.WriteLine();
            string userInput = Console.ReadLine();

            Console.Clear();
            int amountToBuy;
            switch (userInput)
            {
                case "1":
                    Console.WriteLine("How many units would you like to purchase?");
                    string firstInput = Console.ReadLine();
                    
                    while (!int.TryParse(firstInput, out amountToBuy))
                    {
                        Console.WriteLine("Invalid Input\nHow many units would you like to purchase?");  
                       firstInput = Console.ReadLine();
                    }
                    CalculateTotalUnit(amountToBuy, t1, a1, registeringAgent, customerToBeSubscribeID);
                    break;
                case "2":
                    Console.WriteLine("How many units would you like to purchase?");
                    string secondInput = Console.ReadLine();

                    while (!int.TryParse(secondInput, out amountToBuy))
                    {
                        Console.WriteLine("Invalid Input\nHow many units would you like to purchase?");
                        secondInput = Console.ReadLine();
                    }
                    CalculateTotalUnit(amountToBuy, t2, a2, registeringAgent, customerToBeSubscribeID);
                    break;
                case "3":
                    Console.WriteLine("How many units would you like to purchase?");
                    string thirdInput = Console.ReadLine();

                    while (!int.TryParse(thirdInput, out amountToBuy))
                    {
                        Console.WriteLine("Invalid Input\nHow many units would you like to purchase?");
                        thirdInput = Console.ReadLine();
                    }
                    CalculateTotalUnit(amountToBuy, t3, a3, registeringAgent, customerToBeSubscribeID);
                    break;
                case "4":
                    Console.WriteLine("How many units would you like to purchase?");
                    string fourthInput = Console.ReadLine();

                    while (!int.TryParse(fourthInput, out amountToBuy))
                    {
                        Console.WriteLine("Invalid Input\nHow many units would you like to purchase?");
                        fourthInput = Console.ReadLine();
                    }
                    CalculateTotalUnit(amountToBuy, t4, a4, registeringAgent, customerToBeSubscribeID);
                    break;
                default:
                    MakeSubscriptionPayment(registeringAgent, customerToBeSubscribeID);
                    break;
            }

        }

        private void CalculateTotalUnit(int unitToBePurchased, decimal pricePerUnit, string tariffId, string registeringAgent, string customerToBeSubscribeID)
        {
            decimal totalAmountPurchased = Convert.ToDecimal(unitToBePurchased) * pricePerUnit;
            Console.WriteLine($"You are about to pay #{totalAmountPurchased} \nDo you want to proceed? \n1 : Yes\n2 : No  ");
            string entry = Console.ReadLine();
            
            switch (entry)
            {
                case "1":
                    Console.WriteLine($"You have Successfully purchased {unitToBePurchased} Units");

                    var sub = subscriptionServices.CheckActiveSubscription(customerToBeSubscribeID);

                    foreach (var item in sub)
                    {
                        item.SubscriptionStatus = "Inactive";
                        subscriptionServices.UpdateSubscription(item);
                    }

                    Subscriptions subscriptions = new Subscriptions
                    {
                        Id = Guid.NewGuid().ToString(),
                        SubscriptionStatus = "Active",
                        CustomerId = customerToBeSubscribeID,
                        TariffId = tariffId,
                        AgentId = registeringAgent,
                        SubcriptionDateTime = DateTime.Now,
                        Amount = totalAmountPurchased,
                    };
                    
                    subscriptionServices.MakeSubscription(subscriptions);
                    Console.WriteLine("Successfull!!!");
                    Thread.Sleep(3000);
                    break;
                case "2":
                    Console.WriteLine("Cancelled!!!\nRedirecting....");
                    Thread.Sleep(3000);
                    break;
            }

        }


        public void ViewSubscriptionsHistory()
        {
            Console.Clear();
            var userEmailCheck = EmailCheck();

            if (userEmailCheck == "Failed")
            {
                Console.WriteLine("No Valid Email Found");
                Thread.Sleep(3000);
            }
            else
            {
                var customerToBeSubscribeID = agentCustomerServices.GetCustomerByEmail(userEmailCheck).Id;
                var subscriptions = subscriptionServices.GetCustomerSubscription(customerToBeSubscribeID);

                string tariffName;

                if (subscriptions.Count == 0)
                {
                    Console.WriteLine("You have not made any Subscription");
                    Thread.Sleep(3000);
                }
                else
                {
                    Console.WriteLine("Subscription History\n");
                    Console.WriteLine($"{"Tariff Name", -20}\tAmount\t\t\tSubscription Date\t\tSubscription Status\n\n");
                    foreach (var subscription in subscriptions)
                    {
                        tariffName = subscription.TariffId;
                        var customerTariff = tariffServices.GetTarriffById(tariffName);
                        Console.Write($"{customerTariff.Name, -20}\t#{subscription.Amount}\t\t{subscription.SubcriptionDateTime}\t\t{subscription.SubscriptionStatus}\n");
                    }
                    Console.ReadKey();
                }
            }
        }

        private string EmailCheck()
        {
            Console.Clear();
            Console.WriteLine("Please Can I have the Email you used in Registering :");
            Console.Write("The Email Address : ");
            string email = Console.ReadLine();

            while (string.IsNullOrEmpty(email))
            {
                Console.Write("Please Enter an Email Address : ");
                email = Console.ReadLine();
            }

            var customer = agentCustomerServices.GetCustomerByEmail(email);

            if (customer == null)
            {
                return "Failed";
            }
            else
            {
                return customer.EmailAddress;
            }
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.AgentServices.IServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElectricityDigitalSystem.AgentServices
{
    public class AgentCustomerServices : AgentServicesAPI, IAgentCustomerServices
    {

        public string RegisterCustomer(CustomerModel customer)
        {
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }
            //This will Handle registration of a customer
            else
            {
                fileService.Database.Customers.Add(customer);

                fileService.SaveChanges();
                return customer.Id == null ? "Failed" : "Success";
            }
        }

        public CustomerModel GetCustomerById(string customerId)
        {
            CustomerModel foundcustomer = fileService.Database.Customers.Find(c => c.Id == customerId);
            if (foundcustomer != null)
            {
                return foundcustomer;
            }
            return null;
        }

        public List<CustomerModel> GetAllRegisteredCustomer()
        {
            var allCustomers = fileService.Database.Customers.ToList();
            return allCustomers;
        }

        //Find Customer via Email
        public CustomerModel GetCustomerByEmail(string email)
        {
            CustomerModel foundcustomer = fileService.Database.Customers.Find(c => c.EmailAddress == email);
            if (foundcustomer != null)
            {
                return foundcustomer;
            }
            return null;
        }

        public string UpdateCustomer(CustomerModel modifiedcustomer)
        {
            CustomerModel foundCustomer = this.GetCustomerById(modifiedcustomer.Id);
            if (foundCustomer != null)
            {
                //fileService.Database.Customers.IndexOf(foundCustomer);
                //fileService.Database.Customers.Insert(indexOfFoundCustomer, foundCustomer);
                fileService.SaveChanges();
                return "SUCCESS";
            }

            return "FAILURE NOT FOUND";
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Data
{
    public class DbContext
    {
        public List<AgentsModel> Agents { get; set; } = new List<AgentsModel>();

        public List<CustomerModel> Customers { get; set; } = new List<CustomerModel>();
        
        public List<TarriffModel> Tariffs { get; set; } = new List<TarriffModel>();

        public List<Subscriptions> Subcriptions { get; set; } = new List<Subscriptions>();

        public List<ElectricityTariffPayment> TariffPayments { get; set; } = new List<ElectricityTariffPayment>();


    }


}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElectricityDigitalSystem.ClientServices
{
    public class CustomerService : ClientServicesAPI
    {
        public string RegisterCustomer(CustomerModel customer)
        {
            if(customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }
            //This will Handle registration of a customer
            else
            {
                //customer.Id = "CUS-" + Guid.NewGuid().ToString();
                //customer.MeterNumber = "EDS-" + Guid.NewGuid().ToString();
                fileService.Database.Customers.Add(customer);

                fileService.SaveChanges();
                return customer.Id;
            }
        }

        public CustomerModel GetCustomerById(string customerId)
        {
            CustomerModel foundcustomer = fileService.Database.Customers.Find(c => c.Id == customerId);
            if (foundcustomer != null)
            {
                return foundcustomer;
            }
            return null;
        }

        //Find Customer via Email
        public CustomerModel GetCustomerByEmail(string email)
        {
            CustomerModel foundcustomer = fileService.Database.Customers.Find(c => c.EmailAddress == email);
            if (foundcustomer != null)
            {
                return foundcustomer;
            }
            return null;
        }

        public string UpdateCustomer(CustomerModel modifiedcustomer)
        {

           CustomerModel foundCustomer = this.GetCustomerById(modifiedcustomer.Id);
            if (foundCustomer != null)
            {
                 //fileService.Database.Customers.IndexOf(foundCustomer);
                //fileService.Database.Customers.Insert(indexOfFoundCustomer, foundCustomer);
                fileService.SaveChanges();
                return "SUCCESS";
            }

            return "FAILURE NOT FOUND";
        }

        public string RegisterCustomerSubcription(ElectricityTariffPayment electricityTariffPayment)
        {
           
            if (electricityTariffPayment == null)
            {
                throw new ArgumentNullException(nameof(electricityTariffPayment));
            }
            //This ill Handle registration of a customer
            else
            {
                fileService.Database.TariffPayments.Add(electricityTariffPayment);
                fileService.SaveChanges();
                return electricityTariffPayment.MeterNumber;
            }
   
        }

        public ElectricityTariffPayment ViewCustomerSubcriptionStatus(string meterNumber)
        {

            ElectricityTariffPayment customerMeterNumber = fileService.Database.TariffPayments.Find(c => c.MeterNumber == meterNumber);
            if (customerMeterNumber != null)
            {
                return customerMeterNumber;
            }
            return null;
        }

        public bool DeleteSubcription(ElectricityTariffPayment electricityTariffPayment)
        {
            fileService.Database.TariffPayments.Remove(electricityTariffPayment);
            fileService.SaveChanges();
            return true;
        }

    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSAgentPortal.AgentMenu
{
    public class AgentMenuNav
    {
        readonly bool appIsRunning = true;

        public void PageMenuNav()
        {
            AgentMenu agentMenu = new AgentMenu();

            while (appIsRunning == true)
            {
                Console.Clear();
                Console.WriteLine("Welcome To EDS AGENT PORTAL.");
                Console.WriteLine("Choose an Option : \n1. Register \n2. Login \n3. Close the App");
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "1":
                        agentMenu.RegisterAgent();
                        break;
                    case "2":
                        agentMenu.LoginAgent();
                        break;
                    case "3":
                        Environment.Exit(0);
                        break;
                }
            }
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public class BaseUserModel
    {
        public string Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public DateTime CreatedDateTime { get; set; } = DateTime.Now;
        public DateTime ModifiedDateTime { get; set; } = DateTime.Now;
        public string EmailAddress { get; set; }
        public string PhoneNumber { get; set; }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public enum MeterType
    {
        SINGLEPHASE = 1,
        THREEPHASE = 3
    } 
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public class AgentsModel : BaseUserModel
    {
        public AgentsModel() => Id = "AGT-" + Guid.NewGuid().ToString();

        public string Password { get; set; }

    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSAgentPortal.AgentMenu.AgentLogInMenu.AgentPortfolio
{
    public class AgentPortMenuNav
    {
        readonly AgentPortMenu agentPortMenu = new AgentPortMenu();

        public void AgentPortPageMenuNav(string id, string firstName, string lastName)
        {
            bool inLoginPage = true;

            while (inLoginPage)
            {
                Console.Clear();
                Console.WriteLine($"Welcome Agent {firstName} {lastName}");
                Console.WriteLine("Choose an Option : \n1. View Data      \n2. Update Information    \n3. Back To LogIn Menu");
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "1":
                        agentPortMenu.ViewAgentData(id);
                        break;
                    case "2":
                        agentPortMenu.UpdatePersonalInfo(id);
                        break;
                    case "3":
                        inLoginPage = false;
                        break;
                }
            }
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.AgentServices;
using ElectricityDigitalSystem.AgentServices.IServices;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSAgentPortal.AgentMenu.AgentLogInMenu.AgentPortfolio
{
    public class AgentPortMenu
    {
        readonly IAgentServices agentServices = new AgentServices();

        readonly AgentMenuNav agentMenuNav = new AgentMenuNav();

        public void ViewAgentData(string id)
        {
            Console.WriteLine();
            Console.WriteLine($"{"Full Name",-20} : {agentServices.GetAgentById(id).FirstName} {agentServices.GetAgentById(id).LastName}");
            Console.WriteLine($"{"Email Address",-20} : {agentServices.GetAgentById(id).EmailAddress} ");
            Console.WriteLine($"{"Phone Number",-20} : {agentServices.GetAgentById(id).PhoneNumber} "); 
            Console.WriteLine($"{"Created Date Time",-20} : {agentServices.GetAgentById(id).CreatedDateTime} ");
            Console.WriteLine($"{"Modified Date Time",-20} : {agentServices.GetAgentById(id).ModifiedDateTime} ");

            Console.ReadKey();
        }

        public void UpdatePersonalInfo(string id)
        {
            var customerDetail = agentServices.GetAgentById(id);
            
            bool inputAnother;

            do
            {
                Console.WriteLine($"What would you like to Update?\n 1. First Name      2. Last Name        3. Email Address        4. Phone Number     5. Password");
                string response = Console.ReadLine();

                switch (response)
                {
                    case "1":
                        Console.WriteLine("Please enter your new First Name :");
                        customerDetail.FirstName = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "2":
                        Console.WriteLine("Please enter your new Last Name :");
                        customerDetail.LastName = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "3":
                        Console.WriteLine("Please enter your new Email Address :");
                        customerDetail.EmailAddress = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "4":
                        Console.WriteLine("Please enter your new Phone Number :");
                        customerDetail.PhoneNumber = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "5":
                        Console.WriteLine("Please enter your new Password :");
                        customerDetail.Password = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                }

                Console.WriteLine("Would you like to update another information? (Y/N)");
                var continueEditing = Console.ReadLine();

                if (continueEditing.ToLower() == "y")
                {
                    inputAnother = true;
                }
                else
                {
                    inputAnother = false;
                }

            } while (inputAnother);

            agentServices.UpdateAgent(customerDetail);
            
            Console.WriteLine("Successful!!!\nLogging Out....");
            Thread.Sleep(2000);
            agentMenuNav.PageMenuNav();
            
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.AgentServices;
using ElectricityDigitalSystem.Common.ISubscriptionsServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElectricityDigitalSystem.Common
{
    public class SubscriptionServices : AgentServicesAPI, ISubscriptionServices
    {
        public void MakeSubscription(Subscriptions subscription)
        {
            fileService.Database.Subcriptions.Add(subscription);
            fileService.SaveChanges();
        }
        public List<Subscriptions> GetAllSubscription()
        {
            var customerSubscription = fileService.Database.Subcriptions.ToList();
            return customerSubscription;
        }

        public List<Subscriptions> GetCustomerSubscription(string customerId)
        {
            var customerSubscription = fileService.Database.Subcriptions.Where(c => c.CustomerId == customerId).ToList();
            return customerSubscription;
        }

        public Subscriptions FindSubscription(string customerId)
        {
            var subscription = fileService.Database.Subcriptions.Find(s => s.CustomerId == customerId);
            return subscription;
        }

        public void CancelSubcription(string id)
        {
            var subToCancel = FindSubscription(id);
            subToCancel.SubscriptionStatus = "InActive";
        }

        public List<Subscriptions> CheckActiveSubscription(string customerId)
        {
            var activeSubscription = fileService.Database.Subcriptions.Where(x => x.CustomerId == customerId).ToList();
            var Sub = activeSubscription.Where(x => x.SubscriptionStatus == "Active").ToList();
            return Sub;
        }

        public string UpdateSubscription(Subscriptions modifiedSubscription)
        {

            if (modifiedSubscription != null)
            {
               // int indexOfCustomer = fileService.Database.Subcriptions.IndexOf(modifiedSubscription);
                //fileService.database.Customers.Insert(indexOfCustomer, modifiedCustomer);
                fileService.SaveChanges();
                return "SUCCESSFULLY UPDATED";
            }
            return "Failed, Customer not found";
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ElectricityDigitalSystem.Constant
{
    public class FileConstant
    {
        public readonly static string DBFOLDER = Path.Combine(Environment.GetFolderPath
            (Environment.SpecialFolder.Desktop), "SBSC EDS");
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Data;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.ClientServices
{
    public class ClientServicesAPI
    {
        protected JsonFileService fileService = new JsonFileService();
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.AgentServices.IServices
{
    public interface IAgentServices
    {
        string RegisterAgent(AgentsModel agent);

        AgentsModel GetAgentById(string agentId);

        AgentsModel GetAgentByEmail(string email);

        string UpdateAgent(AgentsModel modifiedAgent);
    }
}
<file_sep>﻿using ElectricityDigitalSystem.AgentServices;
using ElectricityDigitalSystem.Common.ISubscriptionsServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ElectricityDigitalSystem.Common
{
    public class TariffServices : AgentServicesAPI, ITariffServices
    {
        public void AddTariffToService()
        {
            //List<TarriffModel> mockData = new List<TarriffModel>();

            TarriffModel tariff1 = new TarriffModel
            {
                Id = Guid.NewGuid().ToString(),
                Name = "Better Home Plan",
                PricePerUnit = 150.40M,

            };
            TarriffModel tariff2 = new TarriffModel
            {
                Id = Guid.NewGuid().ToString(),
                Name = "Best Home Plan",
                PricePerUnit = 250.84M,
            };
            TarriffModel tariff3 = new TarriffModel
            {
                Id = Guid.NewGuid().ToString(),
                Name = "Basic Home Plan",
                PricePerUnit = 120.90M,
            };
            TarriffModel tariff4 = new TarriffModel
            {
                Id = Guid.NewGuid().ToString(),
                Name = "Premium Home Plan",
                PricePerUnit = 300.60M,
            };

            PushToDb(tariff1);
            PushToDb(tariff2);
            PushToDb(tariff3);
            PushToDb(tariff4);
        }

        public void PushToDb(TarriffModel model)
        {
            if (fileService.Database.Tariffs.Count <= 3)
            {
                fileService.Database.Tariffs.Add(model);
                fileService.SaveChanges();

            }

        }

        public List<TarriffModel> GetAllTariff()
        {
            var Tariffs = fileService.Database.Tariffs.ToList();
            return Tariffs;
        }

        public TarriffModel GetTarriffByName(string name)
        {
            var tariff = fileService.Database.Tariffs.Find(t => t.Name == name);
            return tariff;
        }

        public TarriffModel GetTarriffById(string id)
        {
            var tariff = fileService.Database.Tariffs.Find(t => t.Id == id);
            return tariff;
        }

        
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSCustomerPortal.Menu
{
    public class LoginMenuNav
    {
        readonly LoginMenu loginMenu = new LoginMenu();

        public void PageMenu(string id, string firstName, string lastName, string meterNumber)
        {

            bool inLoginPage = true;

            while (inLoginPage)
            {
                Console.Clear();
                Console.WriteLine($"welcome {firstName} {lastName}");
                Console.WriteLine("Welcome To CUSTOMER PORTAL.\n");
                Console.WriteLine("Choose an Option : 1. View Data      2. Update Information       3. Make Subscription\n4. Cancel Subscription      5. View Subscription         6. Log Out");
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "1":
                        loginMenu.ViewCustomerData(id);
                        break;
                    case "2":
                        LoginMenu.UpdatePersonalInfo(id);
                        break;
                    case "3":
                        loginMenu.MakeSubscription(meterNumber);
                        break;
                    case "4":
                        loginMenu.CancelSubscription(meterNumber);
                        break;
                    case "5":
                        loginMenu.ViewSubscription(meterNumber);
                        break;
                    case "6":
                        inLoginPage = false;
                        break;
                }
            

            }

        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSAgentPortal.AgentMenu.AgentLogInMenu.CustomerPortfolio
{
    public class CustomerPortMenuNav
    {

        public void CustomerPortPageMenuNav(string registeringAgent)
        {
            CustomerPortMenu customerPortMenu = new CustomerPortMenu();

            AgentCustomerSubscriptions agentCustomerSubscriptions = new AgentCustomerSubscriptions();

            bool inLoginPage = true;

            while (inLoginPage)
            {
                Console.Clear();
                Console.WriteLine("Welcome To AGENT CUSTOMER'S PAGE.");
                Console.WriteLine("Choose an Option : \n1. Register A Customer \n2. View Customer Details  \n3. View All Registered Customer \n4. Update Customers Information  \n5. Make Subscription  \n6. Cancel Subscription  \n7. View Subscription  \n8. Go Back To LogIn Page");
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "1":
                        customerPortMenu.RegisterCustomer(registeringAgent);
                        break;
                    case "2":
                        customerPortMenu.ViewCustomerInfo();
                        break;
                    case "3":
                        customerPortMenu.ViewAllRegisteredCustomer();
                        break;
                    case "4":
                        customerPortMenu.UpdatePersonalInfo();
                        break;
                    case "5":
                        agentCustomerSubscriptions.MakeSubscription(registeringAgent);
                        break;
                    case "6":
                        agentCustomerSubscriptions.CancelCustomerSubscription();
                        break;
                    case "7":
                       agentCustomerSubscriptions.ViewSubscriptionsHistory();
                        break;
                    case "8":
                        inLoginPage = false;
                        
                        break;
                }
            }
        }
    }
}
<file_sep>﻿using EDSCustomerPortal.Services;
using EDSCustomerPortal.Services.IServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSCustomerPortal.Menu
{
    public class Menu
    {
        readonly MenuNav menuNav = new MenuNav();

        readonly IAuthenticationService authenticationService = new AuthenticationService();

        readonly LoginMenuNav loginMenuNav = new LoginMenuNav();

        public void LoginNavigationPage()
        {
            Dictionary<string, string> navItemDic = new Dictionary<string, string>();

            List<string> navigationItem = new List<string>
            {
                "Email", "Password"
            };
            
            Console.Clear();
            Console.WriteLine("Please Login with your Email and Password");

            for (var i = 0; i < navigationItem.Count; i++)
            {
                Console.Write($"Please Enter your {navigationItem[i]} : ");
                var value = Console.ReadLine();
                navItemDic.Add(navigationItem[i], value);
            }

            string Email, Password;

            Email = navItemDic["Email"];
            Password = navItemDic["Password"];

            var customer = authenticationService.GetCustomerByEmail(Email);
            if (customer == null)
            {
                Console.WriteLine("No Email Found");
                Thread.Sleep(3000);

                menuNav.PageMenu();
            }
            else
            {
                if (customer.Password != Password)
                {
                    Console.WriteLine("Invalid Login Credentials Please Try Again");
                    Thread.Sleep(3000);

                    menuNav.PageMenu();
                }
                else
                {
                    loginMenuNav.PageMenu(customer.Id, customer.FirstName, customer.LastName, customer.MeterNumber);
                        
                }
            }    
        }


        public void RegistrationNavigationPage()
        {
            Dictionary<string, string> navItemDIc = new Dictionary<string, string>();
            List<string> navigationItems = new List<string>
            {
                "FirstName", "LastName", "Email", "Password", "PhoneNumber"
            };
            Console.Clear();
            Console.WriteLine("Please Provide your Details");

            for (int i = 0; i < navigationItems.Count; i++)
            {
                Console.Write($"Enter your {navigationItems[i]} : ");
                var value = Console.ReadLine();
                navItemDIc.Add(navigationItems[i], value);
            }

            string FirstName, LastName, Email, Password, PhoneNumber;
            FirstName = navItemDIc["FirstName"];
            LastName = navItemDIc["LastName"];
            Email = navItemDIc["Email"];
            Password = navItemDIc["Password"];
           // MeterNumber = navItemDIc["MeterNumber"];
            PhoneNumber = navItemDIc["PhoneNumber"];

            CustomerModel model = new CustomerModel
            {
                FirstName = FirstName,
                LastName = LastName,
                EmailAddress = Email,
                Password = <PASSWORD>,
               // MeterNumber = MeterNumber,
                PhoneNumber = PhoneNumber,
            };

            string registrationResponds = authenticationService.RegisterUser(model);
            if (registrationResponds == "Success")
            {
                Console.WriteLine("Registration Successful");
                Console.WriteLine("Redirecting you to Home Page....");
                Thread.Sleep(3000);
            }
            else
                Console.WriteLine("An Error occured While Trying to Create your Account Please try Again");
 
           menuNav.PageMenu();

        }
    }
}
<file_sep>﻿using EDSCustomerPortal.Services;
using EDSCustomerPortal.Services.IServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSCustomerPortal.Menu
{
    public class SubscriptionMenu
    {
        readonly IAuthenticationService authenticationService = new AuthenticationService();

        public void AddSubscription(string meterId, string tariffId, string pricePerUnit, string billCharged, string numberOfUnit)
        {
            Dictionary<string, string> navItemDIc = new Dictionary<string, string>();
            List<string> navigationItems = new List<string>
            {
                "MeterNumber","TariffId", "PricePerUnit", "AmountPaid", "NumberOfUnit"
            };
            Console.Clear();

            navItemDIc.Add(navigationItems[0], meterId);
            navItemDIc.Add(navigationItems[1], tariffId);
            navItemDIc.Add(navigationItems[2], pricePerUnit);
            navItemDIc.Add(navigationItems[3], billCharged);
            navItemDIc.Add(navigationItems[4], numberOfUnit);


            string MeterNumber, TariffId, PricePerUnit, NumberOfUnit, AmountPaid;
            MeterNumber = navItemDIc["MeterNumber"];
            TariffId = navItemDIc["TariffId"];
            PricePerUnit = navItemDIc["PricePerUnit"];
            AmountPaid = navItemDIc["AmountPaid"];
            NumberOfUnit = navItemDIc["NumberOfUnit"];

            ElectricityTariffPayment electricityTariffPayment = new ElectricityTariffPayment()
            {
                MeterNumber = MeterNumber,
                TariffId = TariffId,
                PricePerUnit = PricePerUnit,
                AmountPaid = AmountPaid,
                NumberOfUnit = NumberOfUnit,
            };

            authenticationService.RegisterSubscription(electricityTariffPayment);

            //var checkMeterNumberExist = AuthenticationService.ViewCustomerSubscriptionByMeterNumber(MeterNumber);

            //if (checkMeterNumberExist == null)
            //{
            //    AuthenticationService.RegisterSubscription(electricityTariffPayment);
            //}
            //else
            //{
            //    if (checkMeterNumberExist.MeterNumber == MeterNumber)
            //    {
            //        Console.WriteLine($" Bill Cancelled!!!\nYou're on Subscription... Redirecting...");
            //        Thread.Sleep(3000);

            //    }
            //    else
            //    {
            //        Console.WriteLine($" Validated!!!\n Payment Successfull!!!");
            //        AuthenticationService.RegisterSubscription(electricityTariffPayment);
            //    }
            //}

        }

        public void CalculateElectricityBill(string metreId)
        {
            
                double selectedTariffPlan; string tariffId = null; 
                string numberOfUnit; string priceperUnit = null;
                double billCharged = 0.0d;

                Console.WriteLine("Enter 1. Single Phase     2. Three Phase");
                selectedTariffPlan = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Please enter the number of units you want");
                 numberOfUnit = Console.ReadLine();
                switch (selectedTariffPlan)
                {
                    case 1:
                        Console.WriteLine("You will be charged 25 Naira per Unit.");
                         tariffId = "SP";
                        priceperUnit = "25";
                        billCharged = Convert.ToInt32(numberOfUnit) * Convert.ToInt32(priceperUnit);
                        Console.WriteLine($"Your Bill is : {billCharged}\n Click Enter to Validate and Make Payment ");
                        Console.ReadKey();
                        break;
                    case 2:
                        Console.WriteLine("You will be charged 30 Naira per Unit.");
                        tariffId = "TP";
                        priceperUnit = "30";
                        billCharged = Convert.ToInt32(numberOfUnit) * Convert.ToInt32(priceperUnit);
                        Console.WriteLine($"Your Bill is : {billCharged}\n Click Enter to Validate and Make Payment ");
                        Console.ReadKey();
                    break;
                }

            AddSubscription( metreId, tariffId, priceperUnit, billCharged.ToString(), numberOfUnit);
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Data;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.AgentServices
{
    public class AgentServicesAPI
    {
        protected JsonFileService fileService = new JsonFileService();
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSCustomerPortal.Validate
{
    public class Validation
    {
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.AgentServices.IServices
{
    public interface IAgentCustomerServices
    {
        string RegisterCustomer(CustomerModel customer);

        List<CustomerModel> GetAllRegisteredCustomer();

        CustomerModel GetCustomerById(string customerId);

        CustomerModel GetCustomerByEmail(string email);

        string UpdateCustomer(CustomerModel modifiedcustomer);
    }
}
<file_sep>﻿using EDSAgentPortal.AgentMenu.AgentLogInMenu.AgentPortfolio;
using EDSAgentPortal.AgentMenu.AgentLogInMenu.CustomerPortfolio;
using System;
using System.Collections.Generic;
using System.Text;

namespace EDSAgentPortal.AgentMenu.AgentLogInMenu
{
    public class LogInMenuNav
    { 
        public void LogInPageMenuNav(string id, string firstName, string lastName)
        {
            AgentPortMenuNav agentPortMenuNav = new AgentPortMenuNav();

            CustomerPortMenuNav customerPortMenuNav = new CustomerPortMenuNav();

            bool inLoginPage = true;

            while (inLoginPage)
            {
                Console.Clear();
                Console.WriteLine($"{firstName} {lastName}");
                Console.WriteLine("Welcome To AGENT PORTAL.\n");
                Console.WriteLine("Choose an Option : \n1. AGENT Dashboard     \n2. CUSTOMER Dashboard   \n3. Log Out");
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "1":
                        agentPortMenuNav.AgentPortPageMenuNav(id, firstName, lastName);
                        break;
                    case "2":
                        customerPortMenuNav.CustomerPortPageMenuNav(id);
                        break;
                    case "3":
                        inLoginPage = false;
                        break;
                }
            }
        }
    }
}
<file_sep>﻿using ElectricityDigitalSystem.Constant;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;

namespace ElectricityDigitalSystem.Data
{
    public class JsonFileService
    {
        private readonly string jsonFileName = "edsDb.json";

        public DbContext Database { get; set; }

        public JsonFileService()
        {
            this.OnInit();
        }

        private void OnInit()
        {
            if(!Directory.Exists(FileConstant.DBFOLDER))
            {
                Directory.CreateDirectory(FileConstant.DBFOLDER);  
            }

            if (!File.Exists(Path.Combine(FileConstant.DBFOLDER, jsonFileName)))
            {
                File.Create(Path.Combine(FileConstant.DBFOLDER, jsonFileName)).Close();
                this.Database = new DbContext();
            }
            else
            {
                //if file exist then read the file from the directory
                using StreamReader reader = new StreamReader(Path.Combine(FileConstant.DBFOLDER, jsonFileName));
                {
                    try
                    {
                        //Read all filecontent from the json file
                        string jsonFileContent = reader.ReadToEnd();
                        this.Database = JsonSerializer.Deserialize<DbContext>(jsonFileContent);
                    }
                    catch(Exception)
                    {
                        //If the databse is empty instead of throwing an error just create an instance of the database
                        Database = new DbContext();
                    }
                }
            }
        }

        public void SaveChanges()
        {
            //This will covert the database object in a json and write to a file
            string newJson = JsonSerializer.Serialize(Database);
            File.WriteAllText(Path.Combine(FileConstant.DBFOLDER, jsonFileName), newJson);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSCustomerPortal.AppData
{
    public class CustomerApplicationData
    {   public DateTime LastLoginDate { get; set; }
        public string CurrentCustomerId { get; set; }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ElectricityDigitalSystem.Models
{
    public class MeterModel
    {
        public string Id { get; set; }
        public string MeterNumber { get; set; }
        public MeterType Type { get; set; }
        public string ProductName { get; set; }

    }

    
}
<file_sep>﻿using EDSCustomerPortal.Services;
using EDSCustomerPortal.Services.IServices;
using ElectricityDigitalSystem.ClientServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSCustomerPortal.Menu
{
    public class LoginMenu
    {
        readonly SubscriptionMenu subscriptionMenuNav = new SubscriptionMenu();

        readonly IAuthenticationService authenticationService = new AuthenticationService();
        public void ViewCustomerData(string id)
        {
            Console.WriteLine();
            Console.WriteLine($"{"Full Name",-20} : {authenticationService.GetCustomerById(id).FirstName} {authenticationService.GetCustomerById(id).LastName}");
            Console.WriteLine($"{"Email Address",-20} : {authenticationService.GetCustomerById(id).EmailAddress} ");
            Console.WriteLine($"{"Phone Number",-20} : {authenticationService.GetCustomerById(id).PhoneNumber} ");
            Console.WriteLine($"{"Meter Number",-20} : {authenticationService.GetCustomerById(id).MeterNumber} ");
            Console.WriteLine($"{"Created Date Time", -20} : {authenticationService.GetCustomerById(id).CreatedDateTime} ");
            Console.WriteLine($"{"Modified Date Time",-20} : {authenticationService.GetCustomerById(id).ModifiedDateTime} ");

            Console.ReadKey();
        }

        public static void UpdatePersonalInfo(string id)
        {
            CustomerService service = new CustomerService();
            var customerDetail = service.GetCustomerById(id);
            //var customerDetail = AuthenticationService.GetCustomerById(id);
            bool inputAnother;

            do
            {
                Console.WriteLine($"What would you like to Update?\n 1. First Name      2. Last Name        3. Email Address        4. Phone Number     5. Password");
                string response = Console.ReadLine();

                switch (response)
                {
                    case "1":
                        Console.WriteLine("Please enter your new First Name :");
                        customerDetail.FirstName = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "2":
                        Console.WriteLine("Please enter your new Last Name :");
                        customerDetail.LastName = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "3":
                        Console.WriteLine("Please enter your new Email Address :");
                        customerDetail.EmailAddress = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "4":
                        Console.WriteLine("Please enter your new Phone Number :");
                        customerDetail.PhoneNumber = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                    case "5":
                        Console.WriteLine("Please enter your new Password :");
                        customerDetail.Password = Console.ReadLine();
                        customerDetail.ModifiedDateTime = DateTime.Now;
                        break;
                }

                Console.WriteLine("Would you like to update another information? (Y/N)");
                var continueEditing = Console.ReadLine();

                if (continueEditing.ToLower() == "y")
                {
                    inputAnother = true;
                }
                else
                {
                    inputAnother = false;
                }

            } while (inputAnother);

            //AuthenticationService.UpdateCustomerData(customerDetail);
            service.UpdateCustomer(customerDetail);

            Console.WriteLine("Successful!!!\nLog Out to Effect the Changes....");
            Thread.Sleep(3000);
        }

        public void ViewSubscription(string meterNumber)
        {

            try
            {
                Console.WriteLine();
                Console.WriteLine($"Details for Meter Number : {meterNumber}");

                Console.WriteLine($"{"Tarrif Subscribed To",-25} : {authenticationService.ViewCustomerSubscriptionByMeterNumber(meterNumber).TariffId}");
                Console.WriteLine($"{"Price per Unit",-25} : #{authenticationService.ViewCustomerSubscriptionByMeterNumber(meterNumber).PricePerUnit}");
                Console.WriteLine($"{"Number of Unit",-25} : {authenticationService.ViewCustomerSubscriptionByMeterNumber(meterNumber).NumberOfUnit}");
                Console.WriteLine($"{"Amount Paid",-25} : {authenticationService.ViewCustomerSubscriptionByMeterNumber(meterNumber).AmountPaid}");
                Console.WriteLine($"{"Date of Subscription",-25} : {authenticationService.ViewCustomerSubscriptionByMeterNumber(meterNumber).DateOfPayment}");
                Console.WriteLine();
                

                Console.ReadKey();
            }
            catch (Exception)
            {
                Console.WriteLine("Not Subcribed!!!!\nRedericting....");
                Thread.Sleep(3000);
            }
            
        }

        public void MakeSubscription(string meterId)
        {
            
            try
            {
                subscriptionMenuNav.CalculateElectricityBill(meterId);
                Console.WriteLine($" Validated!!!\n Payment Successfull!!!");
                Thread.Sleep(3000);
            }
            catch (Exception)
            {

                Console.WriteLine("Error!!! Subcription Not Successful.\nRedericting....");
                Thread.Sleep(3000);
            }

        }

        public void CancelSubscription(string meterNumber)
        {
            try
            {
                Console.WriteLine($"Are you sure you want to Cancel Subscription? \nEnter 1. To Continue     2. To Go Back");
                string getInput = Console.ReadLine();
                switch (getInput)
                {
                    case "1":
                        authenticationService.DeleteSubscription(meterNumber);
                        Console.WriteLine("Subscription Cancelled.\nRedirecting....");
                        Thread.Sleep(3000);
                        break;
                    case "2":
                        break;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Not Subcribed!!!!\nRedericting....");
                Thread.Sleep(3000);

            }
            
           
        }

       
    }
}
<file_sep>﻿using EDSCustomerPortal.Services;
using ElectricityDigitalSystem.ClientServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace EDSCustomerPortal.Menu
{
    public class MenuNav
    {
        bool appIsRunning = true;

        public void PageMenu()
        {
            Menu menu = new Menu();

            while (appIsRunning == true)
            {
                Console.Clear();
                Console.WriteLine("Welcome To EDS CUSTOMER PORTAL.");
                Console.WriteLine("Choose an Option : \n1. Login \n2. Register \n3. Close the App");
                string choice = Console.ReadLine();

                switch (choice)
                {
                    case "1":
                        menu.LoginNavigationPage();
                        break;
                    case "2":
                        menu.RegistrationNavigationPage();
                        break;
                    case "3":
                        appIsRunning = false;
                        break;
                }
            }
        }

        
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EDSAgentPortal.Validation
{
    public class ValidationClass
    {  
        public ulong CheckPhoneNumber(string password)
        {
            ulong number;
            while (!ulong.TryParse(password, out number))
            {
                Console.WriteLine("Please enter an 11 digit number");
                Console.Write("Phone Number : ");
                password = Console.ReadLine();
            }
            return number;
        }
    }
}
<file_sep>﻿using EDSCustomerPortal.Services.IServices;
using ElectricityDigitalSystem.ClientServices;
using ElectricityDigitalSystem.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace EDSCustomerPortal.Services
{
    public class AuthenticationService : IAuthenticationService
    {    
        public string RegisterUser(CustomerModel model)
        {
            if(model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            else
            {
                CustomerService service = new CustomerService();
                string id = service.RegisterCustomer(model);
                return id == null ? "Failed" : "Success";
            }
        }

        public CustomerModel GetCustomerByEmail(string email)
        {
            CustomerService service = new CustomerService();
            var customerfound = service.GetCustomerByEmail(email);
            return customerfound;
        }

        public CustomerModel GetCustomerById(string customerId)
        {
            CustomerService service = new CustomerService();
            var customerfound = service.GetCustomerById(customerId);
            return customerfound;   
        }

        //Having Issue when I call the Update method from here
        //public static  UpdateCustomerData(CustomerModel model)
        //{
        //    CustomerService service = new CustomerService();
        //    service.UpdateCustomer(model);
        //    return true;
        //}

        public string RegisterSubscription(ElectricityTariffPayment electricityTariffPayment)
        {
            if (electricityTariffPayment == null )
            {
                throw new ArgumentNullException(nameof(electricityTariffPayment));
            }
            else
            {
                CustomerService service = new CustomerService();
                string meterNumber = service.RegisterCustomerSubcription(electricityTariffPayment);
                return meterNumber == null ? "Failed" : "Success";
            }
        }

        public ElectricityTariffPayment ViewCustomerSubscriptionByMeterNumber(string meterNumber)
        {
            CustomerService service = new CustomerService();
            var customerMeterNumber = service.ViewCustomerSubcriptionStatus(meterNumber);  

            if (customerMeterNumber == null)
            {
                throw new ArgumentNullException(nameof(customerMeterNumber));
            }
            else
            {
                return customerMeterNumber;
            }

        }

        public void DeleteSubscription(string metreId)
        {
            CustomerService service = new CustomerService();

            var customerNumber = service.ViewCustomerSubcriptionStatus(metreId);

            if (customerNumber == null)
            {
                throw new ArgumentNullException(nameof(customerNumber));
            }
            else
            {
                service.DeleteSubcription(customerNumber);
              
            }
        }
    }
}
