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