Example #1
0
        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();
        }
Example #2
0
        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 }));
        }
Example #3
0
        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));
        }