public bool UpdateEmployeeAdminRole(EmployeeAdminRoleDto dto) { var employeeAdminRole = this.db.EmployeeAdminRoles.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id); if (employeeAdminRole != null) { employeeAdminRole.UpdatedOn = DateTime.Now; employeeAdminRole.UpdatedBy = dto.UpdatedBy; employeeAdminRole.Comment = dto.Comment; employeeAdminRole.AdminRoleId = dto.AdminRole.Id; employeeAdminRole.EmployeeId = dto.Employee.Id; this.db.SaveChanges(); return true; } return false; }
public bool AddEmployeeAdminRole(EmployeeAdminRoleDto dto) { if (!this.db.EmployeeAdminRoles.Any(x => x.DeletedOn.HasValue == false && x.Id == dto.Id)) { this.db.EmployeeAdminRoles.Add(new EmployeeAdminRole { CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, UpdatedBy = dto.UpdatedBy, Comment = dto.Comment, AdminRoleId = dto.AdminRole.Id, EmployeeId = dto.Employee.Id }); this.db.SaveChanges(); return true; } return false; }