public ResponseState PromoteStudents(DTOs.Requests.Promotion promotionRequest) { int idStudy; if (promotionRequest.studies == null) { return(ResponseState.Fail); } if (promotionRequest.semester < 1) { return(ResponseState.Fail); } var com = new SqlCommand() { CommandText = "select IDSTUDY from STUDIES where NAME = @studyName" }; com.Parameters.AddWithValue("studyName", promotionRequest.studies); if (executeSelect(com).Count == 0) { return(ResponseState.Fail); } idStudy = (int)executeSelect(com)[0][0]; com = new SqlCommand() { CommandText = "select * from ENROLLMENT WHERE SEMESTER = @semester and IDSTUDY = @idStudy" }; com.Parameters.AddWithValue("semester", promotionRequest.semester); com.Parameters.AddWithValue("idStudy", idStudy); if (executeSelect(com).Count == 0) { return(ResponseState.Fail); } com = new SqlCommand() { CommandText = "procedurePromoteStudents", CommandType = System.Data.CommandType.StoredProcedure, }; com.Parameters.AddWithValue("semester", promotionRequest.semester); com.Parameters.AddWithValue("idStudy", idStudy); ExecuteInsert(com); return(ResponseState.Success); }
public IActionResult StudentPromotions(DTOs.Requests.Promotion promotionRequest) { return(ProcessResponseState(dbService.PromoteStudents(promotionRequest))); }