Exemple #1
0
        public async Task <IActionResult> CreditStatus(string service)
        {
            if (!string.IsNullOrEmpty(service))
            {
                var client  = new HttpClient();
                var user    = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();
                var credits = await client.GetAsync($"http://localhost:800/Payments/Credits/{user.UserName}").Result.Content.ReadAsStringAsync();

                dynamic      json_data_credits = JsonConvert.DeserializeObject(credits);
                CreditCounts creditsFromDb     = JsonConvert.DeserializeObject <CreditCounts>(json_data_credits.ToString());

                if (service.Equals("Name search"))
                {
                    if (creditsFromDb.NameSearch > 0)
                    {
                        return(Redirect("/Products/AddNewProduct"));
                    }
                }

                if (service.Equals("Private Limited Entity"))
                {
                    if (creditsFromDb.PvtLimitedCompany > 0)
                    {
                        return(Redirect("/Company/CompanyApplication"));
                    }
                }
            }

            return(View());
        }
Exemple #2
0
        public async Task <IActionResult> PaymentHistory(bool paymentSuccessful)
        {
            var client          = new HttpClient();
            var user            = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();
            var paymentsHistory = await client.GetAsync($"{Globals.Globals.end_point_payment}{user.UserName}").Result.Content.ReadAsStringAsync();

            var creditsHistory = await client.GetAsync($"{Globals.Globals.end_point_payments_credits}{user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic          json_data = JsonConvert.DeserializeObject(paymentsHistory);
            PaymentsResponse response  = JsonConvert.DeserializeObject <PaymentsResponse>(json_data.ToString());

            dynamic      json_data_credits = JsonConvert.DeserializeObject(creditsHistory);
            CreditCounts credits           = JsonConvert.DeserializeObject <CreditCounts>(json_data_credits.ToString());

            ViewBag.Balance  = response.AccountBalance;
            ViewBag.Payments = response.Payments;
            ViewBag.credits  = credits;

            return(View());
        }
Exemple #3
0
        public async Task <IActionResult> Dashboard()
        {
            ViewBag.title = "Dashboard";

            var user = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();

            ViewBag.Role = user.Role;

            var client = new HttpClient();

            //notifications
            //var notifications_read = await client.GetAsync($"{Globals.Globals.end_point_countReadNotificationsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var notifications_un_read = await client.GetAsync($"{Globals.Globals.end_point_countUnReadNotificationsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var notifications_total = await client.GetAsync($"{Globals.Globals.end_point_countAllNotificationsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.notifications_read    = 0;
            ViewBag.notifications_un_read = 0;
            ViewBag.notifications_total   = 0;


            //products
            //var products_active = await client.GetAsync($"{Globals.Globals.end_point_countAllActiveProductsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var products_in_active = await client.GetAsync($"{Globals.Globals.end_point_countAllInActiveProductsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var products_total = await client.GetAsync($"{Globals.Globals.end_point_countAllProductsForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.products_active    = 0;
            ViewBag.products_in_active = 0;
            ViewBag.products_total     = 0;


            //transactions and payments
            //var payment_history = await client.GetAsync($"{Globals.Globals.end_point_countAllPaymentHistoryForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var transaction_history = await client.GetAsync($"{Globals.Globals.end_point_countAllTransactionHistoryForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.payment_history     = 0;
            ViewBag.transaction_history = 0;

            //feedback
            // read_feedback = await client.GetAsync($"{Globals.Globals.end_point_countAllReadFeedBackForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();
            //var un_read_feedback = await client.GetAsync($"{Globals.Globals.end_point_countAllUnReadFeedBackForBiller}?billercode={user.BillerCode}").Result.Content.ReadAsStringAsync();

            ViewBag.read_feedback    = 0;
            ViewBag.un_read_feedback = 0;


            if (ViewBag.Role == 1)
            {
                return(RedirectToAction("PrincipalDashboard"));
            }
            else if (ViewBag.Role == 2)
            {
                return(RedirectToAction("ExaminerTasks"));
            }

            //var user = db.AspNetUsers.Where(i => i.Email == User.Identity.Name).FirstOrDefault();
            //var client = new HttpClient();
            //var res = await client.GetAsync($"{Globals.Globals.end_point_get_company_applications}").Result.Content.ReadAsStringAsync();
            //db.Dispose();
            //dynamic json_data = JsonConvert.DeserializeObject(res);

            //var data = json_data.data.value;
            //List<mCompany> enqs = JsonConvert.DeserializeObject<List<mCompany>>(data.ToString());


            //List<mCompanyInfor> Summary = new List<mCompanyInfor>();
            //int p = 1;

            //foreach (mCompany item in enqs)
            //{
            //    mCompanyInfor items = new mCompanyInfor();

            //    items.Application_Ref = item.CompanyInfo.Application_Ref;
            //    items.RegNumber = item.CompanyInfo.RegNumber;
            //    items.AppliedBy = item.CompanyInfo.AppliedBy;
            //    items.Name = item.CompanyInfo.Name;
            //    items.No_Of_Directors = item.CompanyInfo.No_Of_Directors;
            //    //items.Objective = item.CompanyInfo.Objective;
            //    items.Date_Of_Application = item.CompanyInfo.Date_Of_Application;
            //    items.Type = item.CompanyInfo.Type;
            //    items.Status = item.CompanyInfo.Status;

            //    Summary.Add(items);
            //    if (p ==3 )
            //    {
            //        //break;
            //    }
            //    p++;
            //}

            //List<mCompanyInfor> rejesteredCompanies = Summary.Where(q => q.AppliedBy == user.UserName).ToList();
            //List<mCompanyInfor> pendingCompanies = Summary.Where(q => q.Status == "Pending").ToList();
            //ViewBag.title = "Summary of Companies";
            //ViewBag.datasource = rejesteredCompanies;
            //ViewBag.companyApplication = pendingCompanies;

            //var resp = await client.GetAsync($"{Globals.Globals.end_point_get_name_searches_by_user_v1}?UserID={user.Email}").Result.Content.ReadAsStringAsync();
            //json_data = JsonConvert.DeserializeObject(resp);

            //data = json_data.data.value;
            //List<mSearch> nameSearches = JsonConvert.DeserializeObject<List<mSearch>>(data.ToString());
            //List<mSearchInfo> nameSearchSummary = new List<mSearchInfo>();

            //foreach(mSearch search in nameSearches)
            //{
            //    nameSearchSummary.Add(search.searchInfo);
            //}

            //ViewBag.nameSearches = nameSearchSummary;
            var resp = await client.GetAsync($"{Globals.Globals.end_point_get_name_searches_by_user_v1}?UserID={user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic json_data = JsonConvert.DeserializeObject(resp);

            var            data         = json_data.data.value;
            List <mSearch> nameSearches = JsonConvert.DeserializeObject <List <mSearch> >(data.ToString());


            List <mSearchInfo> nameSearchSummary = new List <mSearchInfo>();

            foreach (mSearch search in nameSearches)
            {
                nameSearchSummary.Add(search.searchInfo);
            }
            nameSearchSummary    = nameSearchSummary.OrderByDescending(z => z.SearchRef).ToList();
            ViewBag.nameSearches = nameSearchSummary;

            var responsey = await client.GetAsync($"{Globals.Globals.end_point_get_company_application_by_user_id}?UserID={user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic json_dataa = JsonConvert.DeserializeObject(responsey);
            var     dataa      = json_dataa.data.value;
            List <mCompanyResponse> companyApplications = JsonConvert.DeserializeObject <List <mCompanyResponse> >(dataa.ToString());

            companyApplications = companyApplications.OrderByDescending(x => x.companyInfo.Date_Of_Application).ToList();


            var paymentsHistory = await client.GetAsync($"{Globals.Globals.end_point_payment}{user.UserName}").Result.Content.ReadAsStringAsync();

            var creditsHistory = await client.GetAsync($"{Globals.Globals.end_point_payments_credits}{user.UserName}").Result.Content.ReadAsStringAsync();

            dynamic          hist_data = JsonConvert.DeserializeObject(paymentsHistory);
            PaymentsResponse response  = JsonConvert.DeserializeObject <PaymentsResponse>(hist_data.ToString());

            dynamic      json_data_credits = JsonConvert.DeserializeObject(creditsHistory);
            CreditCounts credits           = JsonConvert.DeserializeObject <CreditCounts>(json_data_credits.ToString());

            int paymentsCount = response.Payments.Count();

            if (paymentsCount > 3)
            {
                List <PaymentDto> newPayments = new List <PaymentDto>();
                for (int i = 0; i < 3; i++)
                {
                    newPayments.Add(response.Payments[response.Payments.Count - (i + 1)]);
                }
                response.Payments = newPayments;
            }

            var regEntitiesSummaryResponse = await client.GetAsync($"{Globals.Globals.service_end_point}/{user.UserName}/RegisteredEntities").Result.Content.ReadAsStringAsync();

            dynamic regEntitiesSummaryJson;
            List <RegisteredEntitySummary> entitiesSummary = new List <RegisteredEntitySummary>();

            try
            {
                regEntitiesSummaryJson = JsonConvert.DeserializeObject(regEntitiesSummaryResponse);
                entitiesSummary        = JsonConvert.DeserializeObject <List <RegisteredEntitySummary> >(regEntitiesSummaryJson.ToString());
            }
            catch (Exception ex)
            {
            }



            ViewBag.Balance  = response.AccountBalance;
            ViewBag.Payments = response.Payments;
            ViewBag.credits  = credits;
            if (entitiesSummary.Count > 0)
            {
                ViewBag.RegEntitiesSummary = entitiesSummary;
            }

            ViewBag.EntityApplications = companyApplications;
            List <Queries> query = new List <Queries>();

            foreach (var item in companyApplications)
            {
                var query1 = context.Queries
                             .Where(q => q.applicationRef == item.companyInfo.Application_Ref && q.status == "Pending")
                             .ToList();
                foreach (var query1item in query1)
                {
                    query.Add(query1item);
                }
            }
            ViewBag.Queries = query;

            return(View());
        }