// // GET: /RegoinTemplate/Delete/5 public ActionResult Delete(int id) { IRepository <Models.RegionTemplate> repo = new RegionTemplateRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); }
public ActionResult Delete(int id, FormCollection collection) { try { IRepository <Models.RegionTemplate> repo = new RegionTemplateRepository(); repo.Delete(repo.GetById(id)); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here string name = collection.Get("Name"); int deltawind = 0; if (collection.Get("Deltawind") != null) { deltawind = Convert.ToInt32(collection.Get("Deltawind")); } int deltatemperature = 0; if (collection.Get("Deltatemperature") != null) { deltatemperature = Convert.ToInt32(collection.Get("Deltatemperature")); } int territory = (int)Territory.Region; if (collection.Get("Territory") != null) { territory = Convert.ToInt32(collection.Get("Territory")); } RegionTemplate region = new RegionTemplate() { Name = name, Deltawind = deltawind, Deltatemperature = deltatemperature, Territory = territory }; IRepository <RegionTemplate> repo = new RegionTemplateRepository(); repo.Save(region); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message + ex.Source + ex.StackTrace + ex.InnerException; return(View()); } }
public ActionResult Edit(int id, FormCollection collection) { try { string name = collection.Get("Name"); int deltawind = 0; if (collection.Get("Deltawind") != null) { deltawind = Convert.ToInt32(collection.Get("Deltawind")); } int deltatemperature = 0; if (collection.Get("Deltatemperature") != null) { deltatemperature = Convert.ToInt32(collection.Get("Deltatemperature")); } int territory = (int)Territory.Region; if (collection.Get("Territory") != null) { territory = Convert.ToInt32(collection.Get("Territory")); } RegionTemplate region = new RegionTemplate() { ID = id, Name = name, Deltawind = deltawind, Deltatemperature = deltatemperature, Territory = territory }; IRepository <RegionTemplate> repo = new RegionTemplateRepository(); repo.Update(region); return(RedirectToAction("Index")); } catch { return(View()); } }
// // GET: /RegoinTemplate/Details/5 public ActionResult Details(int id) { IRepository <RegionTemplate> repo = new RegionTemplateRepository(); return(View(repo.GetById(id))); }
// // GET: /RegoinTemplate/ public ActionResult Index() { IRepository <Models.RegionTemplate> repo = new RegionTemplateRepository(); return(View(repo.GetAll())); }