public async Task <IActionResult> OnPostAsync()

        {
            if (ModelState.IsValid)

            {
                var success = await _dbWriteService.Delete(Input);



                if (success)

                {
                    StatusMessage = $"Deleted Video: {Input.Title}.";

                    return(RedirectToPage("Index"));
                }
            }



            // If we got this far, something failed, redisplay form

            return(Page());
        }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = await _dbWriteService.Delete(Input);

                    if (result)
                    {
                        //retrieve deleted entry's navigation properties
                        var itemNumber = _dbReadService.Get <Product>(Input.ProductId)?.ItemNumber;
                        var style      = _dbReadService.Get <Style>(Input.StyleId)?.Name;
                        var location   = _dbReadService.Get <Location>(Input.LocationId)?.Name;
                        //Message sent back to Index razor page
                        StatusMessage = $"Deleted inventory entry for item # {itemNumber} of style {style} at {location}";
                        return(RedirectToPage("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            //something failed, redisplay the form
            return(Page());
        }
Exemple #3
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var note = await _context.Note.FindAsync(id);

            _dbWrite.Delete(note);
            await _dbWrite.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var productPackageType = await _dbReadService.GetSingleRecordAsync <ProductPackageType>(s => s.Id.Equals(id));

            _dbWriteService.Delete(productPackageType);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "ProductPackageTypes", new { id = productPackageType.ProductId }));
        }
Exemple #5
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var noteListItem = await _dbRead.GetSingleRecordAsync <NoteListItem>(n => n.Id.Equals(id));

            _dbWrite.Delete(noteListItem);
            await _dbWrite.SaveChangesAsync();

            return(RedirectToAction("Index", "NoteListItems", new { Id = noteListItem.NoteId }));
        }
Exemple #6
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var productStoreSpecific = await _dbReadService.GetSingleRecordAsync <ProductStoreSpecific>(s => s.Id.Equals(id));

            _dbWriteService.Delete(productStoreSpecific);
            await _dbWriteService.SaveChangesAsync();

            return(RedirectToAction("Index", "ProductStoreSpecificProducts", new { id = productStoreSpecific.ProductId }));
        }
Exemple #7
0
 public async Task <bool> DeleteAsync <TSource>(Expression <Func <TSource, bool> > expression) where TSource : class
 {
     try
     {
         _dbWrite.Delete(expression);
         return(await _dbWrite.SaveChangesAsync());
     }
     catch { }
     return(false);
 }
Exemple #8
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var note = await _dbReadService.GetSingleRecordAsync <Note>(s => s.Id.Equals(id));

            _dbWriteService.Delete(note);
            var response = await _dbWriteService.SaveChangesAsync();

            if (!response)
            {
                TempData["notifyUser"] = "******";
            }

            return(RedirectToAction("Index", "Notes", new { id = note.RequestId }));
        }
Exemple #9
0
        public async Task <bool> DeleteAsync <TSource>(Expression <Func <TSource, bool> > expression) where TSource : class
        {
            try
            {
                var entity = await _dbRead.SingleAsync(expression);

                _dbWrite.Delete(entity);
                return(await _dbWrite.SaveChangesAsync());
            }
            catch
            {
                return(false);
            }
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            if (!_signInManager.IsSignedIn(User))
            {
                return(RedirectToPage("/Account/Login", new { Area = "Identity" }));
            }

            var family = await _dbRead.GetSingleRecordAsync <Family>(f => f.Id.Equals(id));

            _dbWrite.Delete(family);
            await _dbWrite.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var product = await _dbReadService.GetSingleRecordAsync <Supplier>(s => s.Id.Equals(id));

            _dbWriteService.Delete(product);
            var response = await _dbWriteService.SaveChangesAsync();

            if (!response)
            {
                TempData["notifyUser"] = "******";
            }

            return(RedirectToAction(nameof(Index)));
        }
Exemple #12
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var success = await _dbWriteService.Delete(Input);

            if (!success)
            {
                return(Page());
            }
            StatusMessage = $"Deleted Album: {Input.Title}.";
            return(RedirectToPage("Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var success = await _dbWriteService.Delete(Input.UserGenre);

            if (!success)
            {
                return(Page());
            }
            StatusMessage = $"User-Band combination [{Input.GenreTitle} | {Input.Email}] was deleted.";
            return(RedirectToPage("Index"));
        }
Exemple #14
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var user = await _dbReadService.GetSingleRecordAsync <User>(u => u.Id.Equals(id));

            var graphClient = new GraphClient(Configuration, true);
            var graphResult = graphClient.DeleteUser(user.AuthId);

            if (graphResult)
            {
                _dbWriteService.Delete(user);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var success = await _dbWriteService.Delete(Input.UserCourse);

                if (success)
                {
                    StatusMessage = $"User-Course combination [{Input.CourseTitle} | {Input.Email}] was deleted.";
                    return(RedirectToPage("Index"));
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Exemple #16
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var result = await _dbWriteService.Delete(Input);

                if (result)
                {
                    //Message sent back to Index razor page
                    StatusMessage = $"Deleted Style: {Input.Name}";
                    return(RedirectToPage("Index"));
                }
            }
            //something failed, redisplay the form
            return(Page());
        }
Exemple #17
0
        public async Task <Boolean> DeleteAsync(int id)
        {
            try
            {
                //TODO: TWO Queries to delete entity????
                //_dbWriteService.Delete(new Entity{Id = })
                var entity = await _dbReadService.SingleAsync <Course>(d => d.Equals(id));

                _dbWriteService.Delete(entity);

                return(await _dbWriteService.SaveChangesAsync());
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #18
0
        public async Task <bool> DeleteAsync <TSource>(Expression <Func <TSource, bool> > expression) where TSource : class
        {
            try
            {
                //TODO: TWO Queries to delete entity????
                //_dbWriteService.Delete(new Entity{Id = })
                var entity = await _dbReadService.SingleAsync <TSource>(expression);

                _dbWriteService.Delete(entity);

                return(await _dbWriteService.SaveChangesAsync());
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var request = await _dbReadService.GetSingleRecordAsync <Request>(s => s.Id.Equals(id));

            _dbWriteService.Delete(request);

            var response = await _dbWriteService.SaveChangesAsync();

            if (!response)
            {
                TempData["notifyUser"] = "******";
            }

            RequestLogHelper logHelper = new RequestLogHelper();

            logHelper.LogRequestChange(request, _context, RequestLogConstants.RequestDeletedByStaff);

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> OnPostRemoveAsync(int courseId, string userId)
        {
            try
            {
                var userCourse = await _dbReadService.SingleAsync <UserCourse>(uc =>
                                                                               uc.UserId.Equals(userId) &&
                                                                               uc.CourseId.Equals(courseId));

                if (userCourse != null)
                {
                    _dbWriteService.Delete(userCourse);
                    await _dbWriteService.SaveChangesAsync();
                }
            }
            catch
            {
            }
            await FillViewData(userId);

            return(Page());
        }
Exemple #21
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var result = await _dbWriteService.Delete(Input);

                    if (result)
                    {
                        //Message sent back to Index razor page
                        StatusMessage = $"Deleted Location: {Input.Name}";
                        return(RedirectToPage("Index"));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            //something failed, redisplay the form
            return(Page());
        }