public IHttpActionResult PutStandardEmployee(int id, StandardEmployee standardEmployee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != standardEmployee.EmployeeId)
            {
                return(BadRequest());
            }

            db.Entry(standardEmployee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StandardEmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetStandardEmployee(int id)
        {
            StandardEmployee standardEmployee = db.StandardEmployee.Find(id);

            if (standardEmployee == null)
            {
                return(NotFound());
            }

            return(Ok(standardEmployee));
        }
        public IHttpActionResult PostStandardEmployee(StandardEmployee standardEmployee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StandardEmployee.Add(standardEmployee);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = standardEmployee.EmployeeId }, standardEmployee));
        }
        public IHttpActionResult DeleteStandardEmployee(int id)
        {
            StandardEmployee standardEmployee = db.StandardEmployee.Find(id);

            if (standardEmployee == null)
            {
                return(NotFound());
            }

            db.StandardEmployee.Remove(standardEmployee);
            db.SaveChanges();

            return(Ok(standardEmployee));
        }
Exemple #5
0
        static void Main()
        {
            List <IJob>      jobs      = new List <IJob>();
            List <IEmployee> employees = new List <IEmployee>();

            string input = "";

            while ((input = Console.ReadLine()) != "End")
            {
                string[] tokens = input.Split();

                switch (tokens[0])
                {
                case "StandardEmployee":
                    StandardEmployee se = new StandardEmployee(tokens[1]);
                    employees.Add(se);
                    break;

                case "PartTimeEmployee":
                    PartTimeEmployee pte = new PartTimeEmployee(tokens[1]);
                    employees.Add(pte);
                    break;

                case "Job":
                    string    jobName  = tokens[1];
                    double    jobHours = double.Parse(tokens[2]);
                    IEmployee emp      = employees.First(e => e.Name == tokens[3]);
                    Job       job      = new Job(jobName, jobHours, emp);
                    jobs.Add(job);
                    break;

                case "Pass":
                    foreach (var j in jobs.Where(w => w.HoursReqired > 0))
                    {
                        j.Update();
                    }
                    break;

                case "Status":
                    foreach (var j in jobs.Where(w => w.HoursReqired > 0))
                    {
                        Console.WriteLine(j.ToString());
                    }
                    break;
                }
            }
        }
Exemple #6
0
    public void Run()
    {
        string input = string.Empty;

        while ((input = Console.ReadLine()) != "End")
        {
            string[] commandOfArgs = input.Split(' ');
            string   command       = commandOfArgs[0];

            switch (command)
            {
            case "Job":
                string nameOfJob           = commandOfArgs[1];
                int    hoursOfWorkRequired = int.Parse(commandOfArgs[2]);
                string employeeName        = commandOfArgs[3];

                IEmployee employee = employees.First(x => x.Name == employeeName);
                Job       job      = new Job(employee, nameOfJob, hoursOfWorkRequired);
                this.jobs.AddEventListener(job);
                break;

            case "StandardEmployee":
                StandardEmployee standardEmployee = new StandardEmployee(commandOfArgs[1]);
                this.employees.Add(standardEmployee);
                break;

            case "PartTimeEmployee":
                PartTimeEmployee partTimeEmployee = new PartTimeEmployee(commandOfArgs[1]);
                this.employees.Add(partTimeEmployee);
                break;

            case "Pass":
                foreach (var j in this.jobs.ToList())
                {
                    j.Update();
                }
                break;

            case "Status":
                foreach (var j in this.jobs)
                {
                    Console.WriteLine(j.ToString());
                }
                break;
            }
        }
    }
        public IEmployee CreateEmployee(string type, string name)
        {
            Employee employee = null;

            switch (type)
            {
            case "PartTimeEmployee":
                employee = new PartTimeEmployee(name);
                break;

            case "StandardEmployee":
                employee = new StandardEmployee(name);
                break;
            }

            return(employee);
        }
    public static void Main()
    {
        Handler       handler       = new Handler();
        JobRepository jobRepository = new JobRepository(handler);
        Dictionary <string, IEmployee> employeeByName = new Dictionary <string, IEmployee>();

        string input = null;

        while ((input = Console.ReadLine()) != "End")
        {
            string[] inputParams = input.Split();

            switch (inputParams[0])
            {
            case "Job":
                IJob job = CreateJob(inputParams.Skip(1).ToArray(), employeeByName);

                jobRepository.AddJob(job);
                break;

            case "StandardEmployee":
                StandardEmployee standardEmployee = new StandardEmployee(inputParams[1]);

                employeeByName[standardEmployee.Name] = standardEmployee;
                break;

            case "PartTimeEmployee":
                PartTimeEmployee partTimeEmployee = new PartTimeEmployee(inputParams[1]);

                employeeByName[partTimeEmployee.Name] = partTimeEmployee;
                break;

            case "Pass":
                jobRepository.PassWeek();
                break;

            case "Status":
                jobRepository.PrintJobsStatus();
                break;

            case "End":
                return;
            }
        }
    }
Exemple #9
0
        private void CreateEmployee(string command)
        {
            var employeeArgs = command.Split();
            var employeeType = employeeArgs[0];
            var employeeName = employeeArgs[1];

            IEmployee employee = null;

            switch (employeeType)
            {
            case "StandardEmployee":
                employee = new StandardEmployee(employeeName);
                break;

            case "PartTimeEmployee":
                employee = new PartTimeEmployee(employeeName);
                break;
            }

            this.employees.Add(employee);
        }
Exemple #10
0
    private void CreateStandardEmployee(string name)
    {
        StandardEmployee standartEmployee = new StandardEmployee(name);

        this.employees.Add(standartEmployee);
    }