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); }
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); }
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(); }
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(); }
public override void Load() { Kernel.Load(new MyModuleDAL()); Kernel.Bind <IDriversService>().To <DriversService>(); Kernel.Bind <IMapper>().ToMethod(x => Automapper.GetMapper()); }