public async Task <IActionResult> Inscription(int CourseID, int view) { if (_signInManager.IsSignedIn(User)) { var user = await _userManager.GetUserAsync(User); var userID = await _userManager.GetUserIdAsync(user); var data = _lcourse.Inscription(CourseID, userID); if (data.Code == "Done") { return(Redirect("/Inscriptions/Index?area=Inscriptions")); } else { _identityError = data; if (view == 1) { return(Redirect("/Home/Index")); } else { _dataCourse = _lcourse.GetCourseCareer(CourseID); _dataCourse.ErrorMessage = data.Description; return(RedirectToPage("/Home/Details", _dataCourse)); } } } else { return(Redirect("/Identity/Account/Login")); } }
public HttpResponseMessage AddCourse(DataCourse data) { string CourseName = data.CourseName; string CourseCode = data.CourseCode; var db = DbUtils.GetDBConnection(); db.Connection.Open(); using (TransactionScope scope = new TransactionScope()) { var query = db.Query("Course").InsertGetId <int>(new { CourseName = CourseName, CourseCode = CourseCode }); scope.Complete(); // if record is entered successfully , transaction will be committed db.Connection.Close(); return(Request.CreateResponse(HttpStatusCode.OK, query)); } }
public HttpResponseMessage DeleteCourse(DataCourse data) { int id = data.CourseID; var db = DbUtils.GetDBConnection(); db.Connection.Open(); using (TransactionScope scope = new TransactionScope()) { try { db.Query("Course").Where("CourseID", id).Delete(); scope.Complete(); db.Connection.Close(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { scope.Dispose(); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }