Ejemplo n.º 1
0
        public ActionResult Save(ContractorEmployee contractorEmployee)
        {
            if (contractorEmployee.Id == 0)
            {
                var newEmployee = new ContractorEmployee()
                {
                    FullName               = contractorEmployee.FullName,
                    Email                  = contractorEmployee.Email,
                    Description            = contractorEmployee.Description,
                    EmployeeSignificanceId = contractorEmployee.EmployeeSignificanceId,
                    Position               = contractorEmployee.Position,
                    ContractorId           = contractorEmployee.Contractor.Id,
                    TelephoneNo            = contractorEmployee.TelephoneNo,
                    IsActive               = true,
                    AddDate                = DateTime.Now
                };
                _context.ContractorEmployees.Add(newEmployee);
            }
            else
            {
                var contractorEmployeeInDb = _context.ContractorEmployees.SingleOrDefault(c => c.Id == contractorEmployee.Id);
                contractorEmployeeInDb.FullName               = contractorEmployee.FullName;
                contractorEmployeeInDb.Email                  = contractorEmployeeInDb.Email;
                contractorEmployeeInDb.Description            = contractorEmployeeInDb.Description;
                contractorEmployeeInDb.EmployeeSignificanceId = contractorEmployee.EmployeeSignificanceId;
                contractorEmployeeInDb.Position               = contractorEmployee.Position;
                contractorEmployeeInDb.ContractorId           = contractorEmployee.Contractor.Id;
                contractorEmployeeInDb.TelephoneNo            = contractorEmployee.TelephoneNo;
                contractorEmployeeInDb.IsActive               = true;
            }
            _context.SaveChanges();

            return(RedirectToAction("Index", "ContractorEmployee"));
        }
Ejemplo n.º 2
0
        // GET: ContractorEmployees
        public ViewResult Index(ContractorEmployee contractorEmployee)
        {
            var contractorEmployees = _context.ContractorEmployees.Where(c => c.IsActive == true)
                                      .Include(c => c.EmployeeSignificance)
                                      .Include(c => c.Contractor).ToList();

            if (contractorEmployee.Contractor != null)
            {
                if (!String.IsNullOrEmpty(contractorEmployee.Contractor.Name))
                {
                    contractorEmployees = contractorEmployees.Where(c => c.Contractor.Name == contractorEmployee.Contractor.Name).ToList();
                }
            }
            if (contractorEmployee != null)
            {
                if (!String.IsNullOrEmpty(contractorEmployee.FullName))
                {
                    contractorEmployees = contractorEmployees.Where(c => c.FullName == contractorEmployee.FullName).ToList();
                }
            }
            if (contractorEmployee.EmployeeSignificanceId != 0)
            {
                contractorEmployees = contractorEmployees.Where(c => c.EmployeeSignificanceId == contractorEmployee.EmployeeSignificanceId).ToList();
            }


            var searchContractorEmployeesViewModel = new SearchContractorEmployeesViewModel()
            {
                ContractorEmployees   = contractorEmployees,
                EmployeeSignificances = _context.EmployeeSignificances.ToList(),
                Contractor            = new Contractor()
            };

            return(View(searchContractorEmployeesViewModel));
        }
Ejemplo n.º 3
0
    protected void LoadEmployees()
    {
        Console.WriteLine("Loading employees...");

        // In a real application, we'd probably get this from a
        // database.
        employees = new Employee[3];

        employees[0] = new SalariedEmployee("Amy", "Anderson", 28, 100);
        employees[1] = new ContractorEmployee("Tom", "Archer", 35, 110);
        employees[2] = new HourlyEmployee("Fred", "Flintstone", 2000, 5);

        Console.WriteLine("\n");
    }