private void UpdateCDSEmployeeFromAppEmployee(CarPool.Web.Library.Employee cdsEmployee, Employee employee) { //Could check for id match before update //cdsEmployee.PrimaryId = employee.Id; cdsEmployee.FullName = employee.Name; cdsEmployee.Email = employee.Email; cdsEmployee.Phone = employee.PhoneNo; if (cdsEmployee.WorkAddress != null) { cdsEmployee.WorkAddress.Line1 = employee.WorkAddress; } else { cdsEmployee.WorkAddress = CreateNewAddressWithLine1(employee.WorkAddress); } if (cdsEmployee.HomeAddress != null) { cdsEmployee.HomeAddress.Line1 = employee.HomeAddress; } else { cdsEmployee.HomeAddress = CreateNewAddressWithLine1(employee.HomeAddress); } cdsEmployee.PreferredArrivalTimeAtWork = new DateTimeOffset(employee.Arrival.ToUniversalTime()); cdsEmployee.PreferredDepartureTimeFromWork = new DateTimeOffset(employee.Departure.ToUniversalTime()); cdsEmployee.HomeLatitude = Convert.ToDecimal(employee.Latitude); cdsEmployee.HomeLongitude = Convert.ToDecimal(employee.Longitude); cdsEmployee.WorkLatitude = Convert.ToDecimal(employee.WorkLatitude); cdsEmployee.WorkLongitude = Convert.ToDecimal(employee.WorkLongitude); }
private CarPool.Web.Library.Employee AppEmployeeToCDSEmployee(Employee employee) { CarPool.Web.Library.Employee cdsEmployee = new CarPool.Web.Library.Employee(); cdsEmployee.PrimaryId = employee.Id; UpdateCDSEmployeeFromAppEmployee(cdsEmployee, employee); return(cdsEmployee); }
private Employee CDSEmployeeToAppEmployee(CarPool.Web.Library.Employee cdsEmployee) { Employee employee = new Employee(); employee.Id = cdsEmployee.PrimaryId; employee.Name = cdsEmployee.FullName; employee.Email = cdsEmployee.Email; employee.PhoneNo = cdsEmployee.Phone; employee.WorkAddress = cdsEmployee.WorkAddress != null ? cdsEmployee.WorkAddress.Line1 : String.Empty; employee.HomeAddress = cdsEmployee.HomeAddress != null ? cdsEmployee.HomeAddress.Line1 : String.Empty; employee.Arrival = cdsEmployee.PreferredArrivalTimeAtWork.HasValue ? cdsEmployee.PreferredArrivalTimeAtWork.Value.ToDateTime().ToLocalTime() : new DateTime(); employee.Departure = cdsEmployee.PreferredDepartureTimeFromWork.HasValue ? cdsEmployee.PreferredDepartureTimeFromWork.Value.ToDateTime().ToLocalTime() : new DateTime(); employee.Latitude = cdsEmployee.HomeLatitude.HasValue ? Convert.ToDouble(cdsEmployee.HomeLatitude) : 0; employee.Longitude = cdsEmployee.HomeLongitude.HasValue ? Convert.ToDouble(cdsEmployee.HomeLongitude) : 0; employee.WorkLatitude = cdsEmployee.WorkLatitude.HasValue ? Convert.ToDouble(cdsEmployee.WorkLatitude) : 0; employee.WorkLongitude = cdsEmployee.WorkLongitude.HasValue ? Convert.ToDouble(cdsEmployee.WorkLongitude) : 0; return(employee); }