Esempio n. 1
0
        public ActionResult SummaryReport()
        {
            int id = Convert.ToInt32(Session["memberId"].ToString());
            List <ServiceRequest> services           = db.ServiceRequests.Where(a => a.Job.freelancerID == id && a.verified == true).ToList();
            FreelancerClient      freelancerObj      = db.FreelancerClients.Find(id);
            CompetitiveSummary    competitiveSummary = new CompetitiveSummary(freelancerObj);
            ProfitSummary         profitSummary      = new ProfitSummary(id, services);

            if (freelancerObj != null)
            {
                profitSummary.setProfitSummary();
                competitiveSummary.calculateCompetitiveSummary();
            }

            SummaryReportData summary = new SummaryReportData()
            {
                marketRevenue    = Math.Round(competitiveSummary.getRevenue(), 2),
                marketShare      = Math.Round(competitiveSummary.getMarketShare(), 2),
                numFreelancers   = competitiveSummary.getFreelancers(),
                servicesRendered = services.Count(),
                totalCustomers   = services.Count(),
                weeklyEarnings   = profitSummary.weeklyEarnings,
                totalEarnings    = profitSummary.totalEarnings
            };

            return(View(summary));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            int id = Convert.ToInt32(Session["memberId"].ToString());
            List <ServiceRequest> services = db.ServiceRequests.Where(a => a.Job.freelancerID == id && a.verified == true).ToList();

            ProfitSummary profitSummary = new ProfitSummary(id, services);

            profitSummary.setProfitSummary();

            List <Category> categories = new List <Category>();

            // Declare all available departments
            foreach (var item in db.Departments.ToList())
            {
                Category category = new Category();
                category.code = item.departmentCode;
                category.name = item.departmentName;

                foreach (var i in db.ServiceRequests)
                {
                    category.requests = db.ServiceRequests.Where(a => a.Job.FreelancerClient.occupation == category.code).Count();
                }

                categories.Add(category);
            }

            HomeModel homeModel = new HomeModel()
            {
                requests       = db.ServiceRequests.Where(a => a.Job.freelancerID == id && a.verified == false).ToList(),
                totalServices  = services.Count(),
                totalCustomers = services.GroupBy(a => a.customerID).Count(),
                totalIncome    = profitSummary.totalEarnings,
                topCategories  = categories,
                weekEarnings   = profitSummary.weeklyEarnings,
                bestMonthSales = profitSummary.highestSellingMonth,
                monthSales     = profitSummary.highestMonthSales
            };



            return(View(homeModel));
        }