Esempio n. 1
0
 public Company(string name, FieldOfActivity activity, Address address)
 {
     CompanyName = name;
     Activity = activity;
     Address = address;
     ProjectList = new List<Project>();
     PersonList = new List<Person>();
 }
Esempio n. 2
0
        public Contractor(string fName, string lName, DateTime bdate, Dictionary<string, int> skillsDictionary,
            Address address, Company company, double workexp, Salary salary)
            : base(fName, lName, bdate, skillsDictionary, address, company)
        {
            if (workexp <= 0)
                throw new ArgumentException("Work expirience must be positive.");

            WorkExp = workexp;
            Salary = salary;
            taskList = new List<Task>();
        }
Esempio n. 3
0
 public Employee(string fName, string lName, DateTime bdate, Dictionary<string, int> skillsDictionary,
     Address address, Company company, double workexp, Salary salary,
     string department, string role)
     : base(fName, lName, bdate, skillsDictionary,  address, company, workexp, salary)
 {
     if (string.IsNullOrWhiteSpace(department))
         throw new ArgumentException("department is required.");
     Department = department;
     if (string.IsNullOrWhiteSpace(role))
         throw new ArgumentException("department is required.");
     Role = role;
 }
Esempio n. 4
0
        public Employee CreateEmployee(string fName, string lName, DateTime bDate,
            Dictionary<string, int> skillsDictionary, Address address,
            Company company, double workexp, Salary salary,
            string department, string function)
        {
            var employee = new Employee(fName, lName, bDate, skillsDictionary,  address, company, workexp,
                salary, department, function);
            OnEmployeeCreation(employee);
            Logger.Logger.AddToLog("EmployeeFactory|CreateEmployee Employee");
            //var salaryCalculator = new SalaryCalculator();
            //employee.Salary = salaryCalculator.Calculate(employee.Salary, new EmployeeSalaryCalculator());

            return employee;
        }
Esempio n. 5
0
 public Intern CreateIntern(string fName, string lName, DateTime bdate, Dictionary<string, int> skillsDictionary,
     Address address, Company company, double avmark)
 {
     Logger.Logger.AddToLog("InternFactory|CreateIntern Intern");
     var intern = new Intern(fName, lName, bdate, skillsDictionary, address, company, avmark);
     OnInternCreation(intern);
     //IPrivileges a = intern;
     //IPrivileges b = new HollidayPrivilege(a);
     //IPrivileges d = new SalaryBonusPrivilege(b);
     //d.AddPrivilege();
     //var salaryCalculator = new SalaryCalculator();
     //intern.Salary = salaryCalculator.Calculate(intern.Salary, new InternSalaryCalculator());
     return intern;
 }
Esempio n. 6
0
 public void AddAddress(Address address)
 {
     using (var transaction = _session.BeginTransaction())
     {
         try
         {
             _session.SaveOrUpdate(address);
             transaction.Commit();
         }
         catch (Exception ex)
         {
             Logger.Logger.AddToLog("AddressRepository | AddAddress | {0}", ex);
             transaction.Rollback();
         }
     }
 }
Esempio n. 7
0
 public Contractor CreateContractor(string fName, string lName, DateTime bdate,
     Dictionary<string, int> skillsDictionary,
     Address address, Company company, double workexp, Salary salary)
 {
     var contractor = new Contractor(fName, lName, bdate, skillsDictionary,  address, company,
         workexp, salary);
     OnContractorCreation(contractor);
     Logger.Logger.AddToLog("ContractorFactory|CreateContractor Contractor");
     //IPrivileges a = contractor;
     //IPrivileges b = new HollidayPrivilege(a);
     //IPrivileges d = new SalaryBonusPrivilege(b);
     //d.AddPrivilege();
     //var salaryCalculator = new SalaryCalculator();
     //contractor.Salary = salaryCalculator.Calculate(contractor.Salary, new ContractorSalaryCalculator());
     return contractor;
 }
Esempio n. 8
0
 public void UpdateAddress(Address currentAddress, string city, string street)
 {
     using (var transaction = _session.BeginTransaction())
     {
         try
         {
             //var address = _session.Load<Address>(id);
             currentAddress.ChangeAddress(street, city);
             transaction.Commit();
         }
         catch (Exception ex)
         {
             Logger.Logger.AddToLog("AddressRepository | UpdateAddress | {0}", ex);
             transaction.Rollback();
         }
     }
 }
Esempio n. 9
0
        public ActionResult CreateContractor(ContractorModel newcontractor)
        {
            if (ModelState.IsValid)
            {
                var company = CompanyRepository.GetItemById<Company>(newcontractor.CompanyId);
                var address = new Address(newcontractor.Street, newcontractor.City);
                var skill = new Dictionary<string, int>();
                var salary = new Salary(newcontractor.Salary, 0.0);
                var contractor = ContractorFactory.CreateContractor(newcontractor.Firstname, newcontractor.Lastname,
                    newcontractor.BirthDate,
                    skill, address, company, newcontractor.WorkExp, salary);
                PersonRepository.AddPerson(contractor);

                var pers = PersonRepository.GetAllFirstAndLastNames();
                return PartialView("WorkerList", pers);
            }
            return PartialView(newcontractor);
        }
Esempio n. 10
0
        public Person(string fName, string lName, DateTime bdate, Dictionary<string, int> skillsDictionary,
            Address address, Company company)
        {
            if (string.IsNullOrWhiteSpace(fName))
                throw new ArgumentException("First name is required.");
            if (string.IsNullOrWhiteSpace(lName))
                throw new ArgumentException("Last name is required.");
            FName = fName;
            LName = lName;
            try
            {
                DateOfBirth = bdate;
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.Write(LName);
                throw new ArgumentOutOfRangeException("Birthdate is out of range.", e);
            }

            SkillsList = skillsDictionary.Select(x => new PersonSkills(this, x.Key, x.Value)).ToList();
            PrivilegeList = new List<PersonPrivilege>();
            Address = address;
            Company = company;
        }
Esempio n. 11
0
 public Director(string fName, string lName, string bdate, Dictionary<string, int> skillsDictionary, Address address, Company company)
     : base(fName, lName, bdate, skillsDictionary,  address, company)
 {
 }
Esempio n. 12
0
        public ActionResult CreateIntern(InternModel newintern)
        {
            if (ModelState.IsValid)
            {
                var company = CompanyRepository.GetItemById<Company>(newintern.CompanyId);
                var address = new Address(newintern.Street, newintern.City);
                var skill = new Dictionary<string, int>();
                var intern = InternFactory.CreateIntern(newintern.Firstname, newintern.Lastname, newintern.BirthDate,
                    skill, address, company, newintern.AverageMark);
                PersonRepository.AddPerson(intern);

                var pers = PersonRepository.GetAllFirstAndLastNames();
                return PartialView("WorkerList", pers);
            }
            return PartialView(newintern);
        }
Esempio n. 13
0
 public Intern(string fName, string lName, DateTime bdate, Dictionary<string, int> skillsDictionary,
     Address address, Company company, double avmark)
     : base(fName, lName, bdate, skillsDictionary, address, company)
 {
     AverageMark = avmark;
 }