Beispiel #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;
        }
 public ActionResult Edit( int id )
 {
     try
     {
         IUser currentUser = Authorization.GetAuthroizedUser();
         if ( currentUser == null )
             return Redirect( "/" );
         if ( currentUser.IsAgent() )
         {
             ClientModel model = new ClientModel();
             model = model.SelectById( id );
             return View( model );
         }
     }
     catch
     {
         return RedirectToAction( "Index" );
     }
     return RedirectToAction( "Index" );
 }