예제 #1
0
        //
        // GET: /RegoinTemplate/Delete/5

        public ActionResult Delete(int id)
        {
            IRepository <Models.RegionTemplate> repo = new RegionTemplateRepository();

            repo.Delete(repo.GetById(id));
            return(RedirectToAction("Index"));
        }
예제 #2
0
 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());
     }
 }
예제 #3
0
        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());
            }
        }
예제 #4
0
        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());
            }
        }
예제 #5
0
        //
        // GET: /RegoinTemplate/Details/5

        public ActionResult Details(int id)
        {
            IRepository <RegionTemplate> repo = new RegionTemplateRepository();

            return(View(repo.GetById(id)));
        }
예제 #6
0
        //
        // GET: /RegoinTemplate/

        public ActionResult Index()
        {
            IRepository <Models.RegionTemplate> repo = new RegionTemplateRepository();

            return(View(repo.GetAll()));
        }