public void Save(RepositoryPattern.Employee employee) { var isExists = GetUnitOfWork().EmployeeRepository.Get().Where(a => a.EmployeeId == employee.EmployeeId).ToList(); if (isExists.Any()) { var aspUser = GetUnitOfWork().AspNetUsersRepository.Get().Where(a => a.UserName == employee.EmployeeId).FirstOrDefault(); if (employee.Email != null && String.IsNullOrEmpty(aspUser.Email)) { aspUser.Email = employee.Email; GetUnitOfWork().AspNetUsersRepository.Update(aspUser); } employee.UpdatedBy = CreatedBy; employee.IsActive = true; employee.UpdatedDate = DateTime.Now; GetUnitOfWork().EmployeeRepository.Update(employee); } else { employee.CreatedBy = CreatedBy; employee.IsActive = true; employee.CreatedDate = DateTime.Now; GetUnitOfWork().EmployeeRepository.Insert(employee); } GetUnitOfWork().Save(); }
public void InsertEmployee(RepositoryPattern.Employee employee) { employee.CreatedBy = CreatedBy; employee.IsActive = true; employee.CreatedDate = DateTime.Now; GetUnitOfWork().EmployeeRepository.Insert(employee); GetUnitOfWork().Save(); }
public void Save(RepositoryPattern.Employee employee) { var isExists = GetUnitOfWork().EmployeeRepository.Get().Where(a => a.EmployeeId == employee.EmployeeId).ToList(); if (isExists.Any()) { employee.UpdatedBy = CreatedBy; employee.IsActive = true; employee.UpdatedDate = DateTime.Now; GetUnitOfWork().EmployeeRepository.Update(employee); } else { employee.CreatedBy = CreatedBy; employee.IsActive = true; employee.CreatedDate = DateTime.Now; GetUnitOfWork().EmployeeRepository.Insert(employee); } GetUnitOfWork().Save(); }