public string Save(Student student) { if (aStudentGateway.DoesStudentExist(student.Email)) { return("This email already exists"); } Department aDepartment = aDepartmentGateway.GetDepartmentById(student.DepartmentId); student.DepartmentCode = aDepartment.Code; int roll = 0; if (aStudentGateway.DoesBatchExist(student.DepartmentCode, student.Date)) { roll = aStudentGateway.GetLastRoll(student.DepartmentCode, student.Date); roll++; } else { roll = 1; } student.Roll = roll; int rowAffected = aStudentGateway.Save(student); if (rowAffected > 0) { return("Registration Successful"); } return("Registration Failed"); }