예제 #1
0
        public async Task <IActionResult> Delete(CourseDeleteInputModel inputModel)
        {
            await courseService.DeleteCourseAsync(inputModel);

            TempData["ConfirmationMessage"] = "Il corso è stato eliminato ma potrebbe continuare a comparire negli elenchi per un breve periodo, finché la cache non viene aggiornata.";
            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
        public async Task DeleteCourseAsync(CourseDeleteInputModel inputModel)
        {
            int affectedRows = await this.db.CommandAsync($"UPDATE Courses SET Status={nameof(CourseStatus.Deleted)} WHERE Id={inputModel.Id} AND Status<>{nameof(CourseStatus.Deleted)}");

            if (affectedRows == 0)
            {
                throw new CourseNotFoundException(inputModel.Id);
            }
        }
예제 #3
0
        public async Task DeleteCourseAsync(CourseDeleteInputModel inputModel)
        {
            Course course = await dbContext.Courses.FindAsync(inputModel.Id);

            if (course == null)
            {
                throw new CourseNotFoundException(inputModel.Id);
            }

            course.ChangeStatus(CourseStatus.Deleted);
            await dbContext.SaveChangesAsync();
        }
예제 #4
0
        public ActionResult Delete(CourseDeleteInputModel courseDeleteInputModel)
        {
            if (courseDeleteInputModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Course course = this.courseService.GetById(courseDeleteInputModel.CourseId);

            if (course == null)
            {
                return(this.HttpNotFound());
            }

            this.courseService.Delete(course);
            return(this.RedirectToAction("Index", "Home"));
        }
예제 #5
0
        public async Task DeleteCourseAsync(CourseDeleteInputModel inputModel)
        {
            await courseService.DeleteCourseAsync(inputModel);

            memoryCache.Remove($"Course{inputModel.Id}");
        }