示例#1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            if (!Access.HasAccess(8))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            try
            {
                // TODO: Add update logic here
                Branche theBranche = new Branche();
                theBranche           = theBranche.GetById(id);
                theBranche.FullName  = collection["FullName"];
                theBranche.ShortName = collection["ShortName"];
                theBranche.Update(theBranche);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", ex.Message);
                return(RedirectToAction("Error", "Home", route));
            }
        }
示例#2
0
        //
        // GET: /Branch/Details/5

        public ActionResult Details(int id)
        {
            if (!Access.HasAccess(9))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            Branche theBranche = new Branche();

            return(View(theBranche.GetById(id)));
        }
示例#3
0
        //
        // GET: /Branch/Delete/5

        public ActionResult Delete(int id)
        {
            if (!Access.HasAccess(10))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            Branche theBranche = new Branche();

            theBranche = theBranche.GetById(id);
            theBranche.Delete(theBranche);

            return(RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            if (!Access.HasAccess(3))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }

            try
            {
                // TODO: Add update logic here
                User theUser = new User();
                theUser       = theUser.GetById(id);
                theUser.Login = collection["Login"];
                theUser.Email = collection["Email"];
                theUser.Name  = collection["Name"];
                Branche theBranche = new Branche();
                theUser.Branche = theBranche.GetById(Convert.ToInt32(collection["Branche.ID"]));

                string[] arrayRoleID = collection["Roles"].Split(',');

                theUser.ClearRoles();

                foreach (string str in arrayRoleID)
                {
                    int roleID = Convert.ToInt32(str);
                    HardX.Models.Role theRole2 = new HardX.Models.Role();
                    theRole2 = theRole2.GetById(roleID);
                    theUser.Roles.Add(theRole2);
                }


                theUser.Update(theUser);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", ex.Message);
                return(RedirectToAction("Error", "Home", route));
            }
        }