public async Task <IActionResult> Delete()
        {
            IEnumerable <Country> countrys = countryManager.GetCountries();

            foreach (Country country in countrys.ToList())
            {
                await countryManager.Delete(country.Id);
            }

            return(NoContent());
        }
예제 #2
0
        public ActionResult Delete(int id, FormCollection data)
        {
            Country country = _Country.GetById(id);

            _Country.Delete(country);
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public async Task <JsonResult> Delete(int id)
        {
            OperationResult result = await _countryManager.Delete(id);

            var message = result.Type == ResultType.Success
                ? "Country has been deleted"
                : result.BuildMessage();

            var title = "Completed";

            if (result.Type == ResultType.Error)
            {
                title = "Attention";
            }
            else if (result.Type == ResultType.Warning)
            {
                title = "Oops";
            }

            return(Json(new
            {
                title,
                message,
                MessageType = result.Type.ToString().ToLower()
            }));
        }
        //GET
        public ActionResult Delete(int id)
        {
            var dbItem = _countryManager.GetById(id);

            if (dbItem == null)
            {
                throw new NullReferenceException();
            }
            _countryManager.Delete(dbItem);
            return(RedirectToAction("List"));
        }