public Result <Assignment> EditAssign(Assignment assignment, string oldIdentifier) { var result = ValidateAssignment(assignment, true); var allAssignments = assignRepo.FindAssignmentsById(oldIdentifier); if (result.Success) { if (assignment.Identifier != oldIdentifier) { assignRepo.DeleteAssign(assignRepo.FindAssignmentByID(oldIdentifier, assignment.AssignmentIdentifier)); var newIdAssignments = assignRepo.FindAssignmentsById(assignment.Identifier); if (newIdAssignments != null) { assignment.AssignmentIdentifier = newIdAssignments.Count() + 1; } else { assignment.AssignmentIdentifier = 1; } result = ValidateAssignment(assignment); if (!result.Success) { assignRepo.AddAssign(assignment); return(result); } } assignRepo.EditAssign(assignment); } return(result); }