// GET: /<controller>/ public IActionResult Index() { var userClaim = (ClaimsIdentity)User.Identity; var userIdVal = userClaim.Claims.FirstOrDefault <Claim>(c => c.Type == ClaimTypes.NameIdentifier); JobCentre jobCentre = new JobCentre(); var soldDeals = _context.JobCardDeals.Include(i => i.BoughtByUser).Include(i => i.SoldByUser).Include(i => i.JobCard).Where(j => j.SoldBy == int.Parse(userIdVal.Value)).ToList(); ViewBag.SoldDealsInProgressCount = soldDeals.Count <JobCardDeals>(s => s.Status == "In process"); var boughtDeals = _context.JobCardDeals.Include(i => i.BoughtByUser).Include(i => i.SoldByUser).Include(i => i.JobCard).Where(j => j.BoughtBy == int.Parse(userIdVal.Value)).ToList(); ViewBag.BoughtDealsInProgressCount = boughtDeals.Count <JobCardDeals>(b => b.Status == "In process"); var recommendation = _context.Recommendations.Include(u => u.UserIDs).Where(c => c.UserID == int.Parse(userIdVal.Value)).ToList(); ViewBag.RecommendationCount = recommendation.Count <Recommend>(t => t.UserID == int.Parse(userIdVal.Value)); var jobCardId = _context.JobCards.FirstOrDefault <JobCard>(u => u.OwnerID == int.Parse(userIdVal.Value)); ViewBag.ViewJobCount = ViewBag.ViewJobCount = _context.JobCardViews.Count(t => t.JobCard.ID == jobCardId.ID); jobCentre.Sold = soldDeals; jobCentre.Bought = boughtDeals; return(View(jobCentre)); }
public void PrintStatus(JobCentre centre) { foreach (IJob job in centre) { writer.WriteLine(job); } }
public void CreateEmployee(JobCentre centre, string[] parts) { string type = parts[0]; string name = parts[1]; IEmployee current = employeeFactory.Create(type, name); centre.AddEmployees(current); }
public void CreateJob(JobCentre centre, string[] parts) { string nameOfJob = parts[0]; int hours = int.Parse(parts[1]); string nameOfEmployee = parts[2]; IJob current = jobFactory.Create(nameOfJob, hours , centre.FindEmployee(nameOfEmployee)); centre.Register(current); }
static void Main(string[] args) { IReader reader = new Reader(); IWriter writer = new Writer(); Executioner executioner = new Executioner(new JobFactory(), new EmployeeFactory(), writer); JobCentre jobCentre = new JobCentre(); Engine engine = new Engine(reader, executioner, jobCentre); engine.Run(); }
public Engine(IReader reader, Executioner executioner, JobCentre centre) { this.reader = reader; this.executioner = executioner; this.centre = centre; this.functions = new Dictionary <string, Action <string[]> >() { { "Job", strings => this.executioner.CreateJob(this.centre, strings.Skip(1).ToArray()) }, { "StandardEmployee", strings => this.executioner.CreateEmployee(this.centre, strings) }, { "PartTimeEmployee", strings => this.executioner.CreateEmployee(this.centre, strings) }, { "Pass", strings => this.executioner.PassWeek(this.centre) }, { "Status", strings => this.executioner.PrintStatus(this.centre) } }; }
public void PassWeek(JobCentre centre) { centre.Notify(); }