Ejemplo n.º 1
0
        public static dynamic GetAuthroizedUser()
        {
            dynamic CurrentUser = null;
            try
            {
                HttpSessionState session = HttpContext.Current.Session;
                string model = session[ "Model" ].ToString();
                int id = Int32.Parse( session[ "UserId" ].ToString() );
                if ( model.Equals( "Agent" ) )
                {
                    AgentModel connector = new AgentModel();
                    CurrentUser = connector.SelectById( id );
                }
                else if ( model.Equals( "Client" ) )
                {
                    ClientModel connector = new ClientModel();
                    CurrentUser = connector.SelectById( id );
                }
            }
            catch
            {
                return null;
            }

            return CurrentUser;
        }
Ejemplo n.º 2
0
 public ActionResult Edit(int id)
 {
     try
     {
         IUser currentUser = Authorization.GetAuthroizedUser();
         if ( currentUser == null )
             return Redirect( "/" );
         if ( currentUser.IsSuperuser() )
         {
             AgentModel model = new AgentModel();
             model = model.SelectById( id );
             return View( model );
         }
     }
     catch
     {
         return RedirectToAction( "Index" );
     }
     return RedirectToAction( "Index" );
 }