Пример #1
0
        public IEnumerable <CompanyModel> GetAllCompanies()
        {
            var companies      = database.Companies.GetAll().ToList();
            var mapper         = Automapper.GetMapper();
            var companiesModel = companies.Select(x => mapper.Map(x, typeof(Company), typeof(CompanyModel)) as CompanyModel).ToList();

            return(companiesModel);
        }
Пример #2
0
        public IEnumerable <EmployeeModel> GetAllEmloyees()
        {
            var employees      = database.Employees.GetAll().ToList();
            var mapper         = Automapper.GetMapper();
            var employeesModel = employees.Select(x => mapper.Map(x, typeof(Employee), typeof(EmployeeModel)) as EmployeeModel).ToList();

            return(employeesModel);
        }
Пример #3
0
        public void EditCompany(CompanyModel model)
        {
            var     mapper  = Automapper.GetMapper();
            Company company = mapper.Map <CompanyModel, Company>(model);

            //Company company = new Company { Id = model.Id, Name = model.Name, Address = model.CompanyAddress };
            database.Companies.Update(company);
            database.Save();
        }
Пример #4
0
        public void AddEmployee(EmployeeModel model)
        {
            var      mapper   = Automapper.GetMapper();
            Employee employee = mapper.Map <EmployeeModel, Employee>(model);

            //Employee employee = new Employee { FirstName = model.FirstName, LastName = model.LastName, Age = model.Age };
            database.Employees.Create(employee);
            database.Save();
        }
Пример #5
0
 public override void Load()
 {
     Kernel.Load(new MyModuleDAL());
     Kernel.Bind <IDriversService>().To <DriversService>();
     Kernel.Bind <IMapper>().ToMethod(x => Automapper.GetMapper());
 }