Esempio n. 1
0
        public int AddEmployee(EmployeeContract employeeContract)
        {
            EmployeeDetail emp = new EmployeeDetail()
            {
                Name   = employeeContract.Name,
                Email  = employeeContract.Email,
                Salary = employeeContract.Salary
            };

            employeeManagementEntitiesObj.EmployeeDetails.Add(emp);
            return(employeeManagementEntitiesObj.SaveChanges());
        }
Esempio n. 2
0
        public int UpdateEmployee(EmployeeContract employeeContract, int EmpId)
        {
            EmployeeDetail employee = employeeManagementEntitiesObj.EmployeeDetails.Find(EmpId);

            if (employee != null)
            {
                employee.Email  = employeeContract.Email;
                employee.Name   = employeeContract.Name;
                employee.Salary = employeeContract.Salary;
                return(employeeManagementEntitiesObj.SaveChanges());
            }
            else
            {
                throw new Exception("Employee do not exists");
            }
        }
Esempio n. 3
0
        public EmployeeContract GetEmployeeByEmail(string email)
        {
            EmployeeDetail employeeDetail = (from a in employeeManagementEntitiesObj.EmployeeDetails
                                             where a.Email == email
                                             select a).FirstOrDefault();

            if (employeeDetail != null)
            {
                EmployeeContract employeeContract = new EmployeeContract()
                {
                    Name   = employeeDetail.Name,
                    Email  = employeeDetail.Email,
                    Salary = employeeDetail.Salary,
                    Id     = employeeDetail.id
                };
                return(employeeContract);
            }
            return(null);
        }