Exemplo n.º 1
0
        public ActionResult Create(TariffModel model)
        {
            IUser currentUser = Authorization.GetAuthroizedUser();
            if ( currentUser == null )
                return Redirect( "/" );

            if ( currentUser.IsSuperuser() )
            {
                try
                {
                    if ( ModelState.IsValid )
                    {
                        model.Insert( model );

                        return RedirectToAction( "Index" );
                    }
                }
                catch
                {
                    return View( model );
                }
            }

            return View( model );
        }
Exemplo n.º 2
0
        //
        // GET: /Loan/Create

        public ActionResult Create()
        {
            IUser currentUser = Authorization.GetAuthroizedUser();
            if ( currentUser == null )
                return Redirect( "/" );

            if ( currentUser.IsClient() )
            {
                List<TariffModel> tariffs;
                try
                {
                    TariffModel tariffModel = new TariffModel();
                    tariffs = tariffModel.SelectAll().ConvertAll( x => ( TariffModel ) x );
                }
                catch
                {
                     tariffs = new List<TariffModel>();
                }
                ViewData[ "tariffs" ] = tariffs;
            }
            else
            {
                return Redirect( "/" );
            }
            return View();
        } 
Exemplo n.º 3
0
        public ActionResult Delete(int id)
        {
            try
            {
                IUser currentUser = Authorization.GetAuthroizedUser();

                if ( currentUser.IsSuperuser() )
                {
                    TariffModel connector = new TariffModel();
                    connector.DeleteById( id );
                }
            }
            catch
            {
                return RedirectToAction( "Index" );
            }
            return RedirectToAction( "Index" );
        }
Exemplo n.º 4
0
        public ActionResult Edit( int id )
        {
            try
            {
                IUser currentUser = Authorization.GetAuthroizedUser();

                if ( currentUser.IsSuperuser() )
                {
                    TariffModel model = new TariffModel();
                    model = model.SelectById( id );
                    return View( model );
                }
            }
            catch
            {
                return RedirectToAction( "Index" );
            }

            return RedirectToAction( "Index" );
        }
Exemplo n.º 5
0
        public ActionResult Index()
        {
            IUser currentUser = Authorization.GetAuthroizedUser();
            if ( currentUser == null )
                return Redirect( "/" );

            try
            {
                if ( currentUser.IsSuperuser() )
                {
                    TariffModel model = new TariffModel();
                    List<TariffModel> tariffList = model.SelectAll().ConvertAll( x => ( TariffModel ) x );
                    ViewData[ "tariffList" ] = tariffList;
                    return View();
                }
            }
            catch
            {
                ViewData[ "tariffList" ] = new List<TariffModel>();
                return View();
            }
            return Redirect( "/" );
        }
Exemplo n.º 6
0
        public ActionResult Edit( int id, TariffModel model )
        {
            try
            {
                IUser currentUser = Authorization.GetAuthroizedUser();

                if ( currentUser.IsSuperuser() && ModelState.IsValid )
                {
                    model.Update( id, model );
                    return RedirectToAction( "Index" );
                }
            }
            catch
            {
                return RedirectToAction( "Index" );
            }
            return View( model );
        }