public async Task DeleteAsync(PartnerDeleteServiceModel partner) { var partnerForDelete = this.db.Partners.Where(a => a.Id == partner.Id).First(); this.db.Partners.Remove(partnerForDelete); await this.db.SaveChangesAsync(); }
public IActionResult DeleteConfirmed(PartnerDeleteServiceModel partner) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(PartnerController.Delete), new { id = partner.Id })); } this.partnerService.DeleteAsync(partner); TempData[WebConstants.TempDataSuccessMessageKey] = ($"Partner {partner.Name} successfuly deleted."); return(RedirectToAction(nameof(PartnerController.Index), new { page = 1 })); }
public async Task <IActionResult> Delete(int id) { var partner = await this.partnerService.ByIdAsync(id); if (partner == null) { return(BadRequest()); } var partnerForDelete = new PartnerDeleteServiceModel { Id = id, Name = partner.Name }; return(View(partnerForDelete)); }