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()); }
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()); }
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 })); }
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 })); }
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 })); }
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); }
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 })); }
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))); }
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")); }
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()); }
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()); }
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); } }
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()); }
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()); }