Esempio n. 1
0
        public CompanyEmployee EmployCitizen(EmployCitizenParameters pars)
        {
            var company = companyRepository
                          .Include(c => c.CompanyEmployees)
                          .FirstOrDefault(c => c.ID == pars.CompanyID);

            CompanyEmployee employee = new CompanyEmployee()
            {
                CitizenID = pars.CitizenID,
                MinHP     = pars.ContractOffer == null ? company.DefaultMinHP : pars.ContractOffer.MinHP,
                Salary    = (decimal)pars.Salary,
                StartDay  = GameHelper.CurrentDay
            };

            if (pars.ContractOffer != null)
            {
                var contract = pars.ContractOffer;
                employee.JobContract = new JobContract()
                {
                    Length    = contract.Length,
                    MinHP     = contract.MinHP,
                    MinSalary = contract.MinSalary,
                    SigneeID  = contract.SigneeID
                };
            }



            company.CompanyEmployees.Add(employee);
            jobOfferService.TakeJobOffer(pars.JobOfferID);

            companyRepository.SaveChanges();

            return(employee);
        }