Esempio n. 1
0
        //
        // GET: /Abonent/Delete/5

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

            repo.Delete(repo.GetById(id));
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                string param_name        = collection.Get("Name");
                IRepository <Group> repo = new GroupRepository();
                Group group = new Group();
                group      = repo.GetById(id);
                group.Name = param_name;
                group.ClearAbonents();
                if (collection.Get("Abonents") != null)
                {
                    string   param_abonents = collection.Get("Abonents");;
                    string[] arrayAbonents  = param_abonents.Split(',');

                    foreach (string str in arrayAbonents)
                    {
                        int     AbonentID = Convert.ToInt32(str);
                        Abonent abonent   = new Abonent();
                        IRepository <Abonent> repo_abonent = new AbonentRepository();
                        abonent = repo_abonent.GetById(AbonentID);

                        group.Abonents.Add(abonent);
                    }
                }

                repo.Update(group);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 3
0
        //
        // GET: /Abonent/Edit/5

        public ActionResult Edit(int id)
        {
            IRepository <Group> repo_groups = new GroupRepository();

            @ViewBag.Groups = repo_groups.GetAll();

            IRepository <Abonent> repo = new AbonentRepository();

            return(View(repo.GetById(id)));
        }
Esempio n. 4
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         IRepository <Models.Abonent> repo = new AbonentRepository();
         repo.Delete(repo.GetById(id));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 5
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                string param_name          = collection.Get("Name");
                string param_email         = collection.Get("Email");
                IRepository <Abonent> repo = new AbonentRepository();
                Abonent abonent            = new Abonent();
                abonent       = repo.GetById(id);
                abonent.Name  = param_name;
                abonent.Email = param_email;
                abonent.ClearGroups();
                string   param_groups;
                string[] arrayGroups;

                if (collection.Get("Groups") != null)
                {
                    param_groups = collection.Get("Groups");;
                    arrayGroups  = param_groups.Split(',');

                    foreach (string str in arrayGroups)
                    {
                        int   GroupID = Convert.ToInt32(str);
                        Group group   = new Group();
                        IRepository <Group> repo_group = new GroupRepository();
                        group = repo_group.GetById(GroupID);

                        abonent.Groups.Add(group);
                    }
                }


                repo.Update(abonent);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 6
0
        //
        // GET: /Abonent/Details/5

        public ActionResult Details(int id)
        {
            IRepository <Abonent> repo = new AbonentRepository();

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