Exemple #1
0
        public void DeleteReview(Review review)
        {
            if (review != null)
            {
                var likes = review.Likes;
                if (likes != null)
                {
                    foreach (var like in likes)
                    {
                        _context.Remove(like);
                    }
                }
                var cmts = review.Comments;
                if (cmts != null)
                {
                    foreach (var cmt in cmts)
                    {
                        _context.Remove(cmt);
                    }
                }

                _context.Reviews.Remove(review);
            }
            _context.SaveChanges();
        }
Exemple #2
0
        public async Task <IActionResult> DeleteConfirmed(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }
            var accounting = await _context.Accountings.Undelited().Include(c => c.ServiceRequset)
                             .FirstOrDefaultAsync(c => c.Id == id && c.ServiceRequset.AcademyId == User.GetAcademy().Id);

            if (accounting == null)
            {
                return(BadRequest());
            }
            var reqid = accounting.ServiceRequsetId;

            _context.Remove(accounting);
            await _context.SaveChangesWithHistoryAsync(HttpContext);

            return(RedirectToAction(nameof(accounting), new { id = reqid }));
        }