Esempio n. 1
0
        public EmployeeModel GetEmployeeById(List <Staff> employees, int PersonId)
        {
            var employee = employees.Where(s => s.PersonId == PersonId).FirstOrDefault();

            if (employee == null)
            {
                throw new Exception(string.Format(Messages.EmployeeNotExists, PersonId));
            }
            var Mapper = MapperHelper.CreateMap <Staff, EmployeeModel>();

            return(Mapper.Map <EmployeeModel>(employee));
        }
Esempio n. 2
0
        public ProjectModel GetProjectById(List <ProjectInfo> projects, int ProjectId)
        {
            var project = projects.Where(s => s.ProjectId == ProjectId).FirstOrDefault();

            if (project == null)
            {
                throw new Exception(string.Format(Messages.ProjectNotExists, ProjectId));
            }
            var Mapper = MapperHelper.CreateMap <ProjectInfo, ProjectModel>();

            return(Mapper.Map <ProjectModel>(project));
        }
Esempio n. 3
0
 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());
     }
 }
Esempio n. 4
0
 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());
     }
 }
Esempio n. 5
0
        public List <EmployeeModel> GetEmployeesList(List <Staff> employees)
        {
            var Mapper = MapperHelper.CreateMap <Staff, EmployeeModel>();

            return(employees.ConvertAll(f => Mapper.Map <EmployeeModel>(f)));
        }