Esempio 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 );
        }
Esempio 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();
        } 
Esempio 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" );
        }
Esempio 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" );
        }
Esempio 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( "/" );
        }
Esempio 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 );
        }