public string Save(CourseAssign courseAssign) { if (courseAssignGateway.IsSubjectExsists(courseAssign)) { return("The Course is already Assigned"); } else { float Credit = Convert.ToSingle(courseAssignGateway.GetCourseId(courseAssign.CourseCode).Credit); float AvailableCredit = Convert.ToSingle(courseAssignGateway.GetAvailableCreditByTeacherId(courseAssign.TeacherId).ReminingCredit); float RemainingCredit = (AvailableCredit - Credit); int rowAffect = courseAssignGateway.UpdateTeacher(courseAssign.TeacherId, RemainingCredit); if (rowAffect > 0) { int affect = courseAssignGateway.Save(courseAssign); if (affect > 0) { return("Save Successfully"); } else { return("Failed"); } } else { return("Failed"); } } }