// Save Item public EmployeeResponse SaveEmployee(EmployeeRequest request) { var response = new EmployeeResponse(); if (request.Employee != null) { Employee employee = null; // Check if Edit or Add if (request.Employee.Id > 0) { // Edit employee = Olympus._Enterprise.Employees.Where(x => x.Id == request.Employee.Id).SingleOrDefault(); if (employee != null) { // Overrides the Salary By Hour //request.Employee.SalaryByHour = employee.SalaryByHour; //Mapper.Map(request.Employee, employee); } } else { // Add if (request.Employee.Code != null) { // Check some info from AlienDB employee = new Employee(); Mapper.Map(request.Employee, employee); Olympus._Enterprise.Employees.AddObject(employee); } } Olympus._Enterprise.SaveChanges(); if (employee != null) response.EmployeeId = employee.Id; } return response; }
/// <summary> /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToEmployees(Employee employee) { base.AddObject("Employees", employee); }
/// <summary> /// Create a new Employee object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="personId">Initial value of the PersonId property.</param> /// <param name="code">Initial value of the Code property.</param> /// <param name="userAccountId">Initial value of the UserAccountId property.</param> /// <param name="salaryByHour">Initial value of the SalaryByHour property.</param> public static Employee CreateEmployee(global::System.Int32 id, global::System.Int32 personId, global::System.String code, global::System.Int32 userAccountId, global::System.Decimal salaryByHour) { Employee employee = new Employee(); employee.Id = id; employee.PersonId = personId; employee.Code = code; employee.UserAccountId = userAccountId; employee.SalaryByHour = salaryByHour; return employee; }