Beispiel #1
0
        //
        // GET: /Territory/Edit/5

        public ActionResult Edit(int id)
        {
            IRepository <Territory> repo = new TerritoryRepository();

            ViewBag.Regions = RegionRepository.GetAllForTerritory();
            return(View(repo.GetById(id)));
        }
Beispiel #2
0
        //
        // GET: /Territory/Delete/5

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

            repo.Delete(repo.GetById(id));
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         IRepository <Models.Territory> repo = new TerritoryRepository();
         repo.Delete(repo.GetById(id));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #4
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                string    name               = collection.Get("Name");
                Territory Territory          = new Territory();
                IRepository <Territory> repo = new TerritoryRepository();
                Territory = repo.GetById(id);
                Territory.ClearRegions();
                Territory.Name = name;
                string   param_regions;
                string[] arrayRegions;
                if (collection.Get("Regions") != null)
                {
                    param_regions = collection.Get("Regions");;
                    arrayRegions  = param_regions.Split(',');

                    foreach (string str in arrayRegions)
                    {
                        int    RegionID = Convert.ToInt32(str);
                        Region region   = new Region();
                        IRepository <Region> repo_region = new RegionRepository();
                        region = repo_region.GetById(RegionID);

                        Territory.Regions.Add(region);
                    }
                }

                repo.Update(Territory);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
        //
        // GET: /Territory/Details/5

        public ActionResult Details(int id)
        {
            IRepository <Territory> repo = new TerritoryRepository();

            return(View(repo.GetById(id)));
        }