public int CreateEmployee(EmployeeModel model) { try { var Mapper = MapperHelper.CreateMap <EmployeeModel, Staff>(); var employee = Mapper.Map <Staff>(model); using (ProjectsDB db = new ProjectsDB()) { db.Staff.Add(employee); db.SaveChanges(); return(db.Staff.Where(s => s.Email == model.Email).Select(s => s.PersonId).FirstOrDefault()); } } catch (Exception ex) { throw new DBException("CreateEmployee(): ", ex.ToString()); } }
public int CreateProject(ProjectModel model) { try { var Mapper = MapperHelper.CreateMap <ProjectModel, ProjectInfo>(); var project = Mapper.Map <ProjectInfo>(model); using (ProjectsDB db = new ProjectsDB()) { db.ProjectInfo.Add(project); db.SaveChanges(); int Id = db.ProjectInfo.Where(p => p.ClientCompanyName == model.ClientCompanyName && p.StartDate == model.StartDate).Select(s => s.ProjectId).FirstOrDefault(); AddProjectExecutor(Id, model.ProjectManagerId); return(Id); } } catch (Exception ex) { throw new DBException("CreateProject(): ", ex.ToString()); } }
public List <EmployeeModel> GetEmployeesList(List <Staff> employees) { var Mapper = MapperHelper.CreateMap <Staff, EmployeeModel>(); return(employees.ConvertAll(f => Mapper.Map <EmployeeModel>(f))); }