// GET: CountryPublisheds/Details/5 public async Task <ActionResult> Details(int?id) { CountryViewModel model; try { if (id == null) { //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); return(PartialView("PartialNotFound", id.ToString())); } CountryPublished countryPublished = await db.CountryPublisheds.FindAsync(id); if (countryPublished == null) { //return HttpNotFound(); return(PartialView("PartialNotFound", id.ToString())); } model = CauntryRelase.DetailsCountry(countryPublished); return(View(model)); } catch { return(RedirectToAction("Index")); } }
public ActionResult Index() { try { var countries = db.CountryPublisheds.ToList(); CauntryListModel model = new CauntryListModel { CountryList = CauntryRelase.GetCountryResult(countries) }; return(View(model.CountryList)); //return View(await db.CountryPublisheds.ToListAsync()); } catch { return(RedirectToAction("Index")); } }
public async Task <ActionResult> Edit([Bind(Include = "Id,CountryName,IsoCode,PhoneCode")] CountryViewModel mod) { try { if (ModelState.IsValid) { var country = CauntryRelase.EditCountry(mod); db.Entry(country).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(mod)); } catch { return(RedirectToAction("Index")); } }
public async Task <ActionResult> Create([Bind(Include = "Id,CountryName,IsoCode,PhoneCode")] CountryViewModel model) { try { if (ModelState.IsValid) { var country = CauntryRelase.CreateCountry(model); db.CountryPublisheds.Add(country); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); } catch { return(RedirectToAction("Index")); } }