Exemplo n.º 1
0
 // GET: Dishes/Create
 public ActionResult Create()
 {
     if (AuthenticationTools.UserHasRole(currentUserName, "StaffMember,Boss,Admin"))
     {
         ViewBag.DishCategoryID = new SelectList(db.DishCategories, "ID", "Name");
         return(View());
     }
     return(RedirectToAction("Login", "Account"));
 }
Exemplo n.º 2
0
 // GET: Dishes
 public ActionResult Index()
 {
     if (AuthenticationTools.UserHasRole(currentUserName, "StaffMember,Boss,Admin"))
     {
         var dishes = db.Dishes.Include(d => d.DishCategory);
         return(View(dishes.ToList()));
     }
     return(RedirectToAction("Login", "Account"));
 }
Exemplo n.º 3
0
        // GET: Companies/Create
        public ActionResult Create()
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            ViewBag.StatusID = new SelectList(db.States, "ID", "Name");
            ViewBag.LevelID  = new SelectList(db.Levels, "ID", "Name");
            return(View());
        }
Exemplo n.º 4
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (AuthenticationTools.UserHasRole(currentUserName, "StaffMember,Boss,Admin"))
     {
         Dish dish = db.Dishes.Find(id);
         db.Dishes.Remove(dish);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Login", "Account"));
 }
Exemplo n.º 5
0
        // GET: Companies
        public ActionResult Index()
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            var companies = db.Companies.Include(c => c.State).Include(c => c.Level);

            return(View(companies.ToList()));
        }
Exemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            Company company = db.Companies.Find(id);

            db.Companies.Remove(company);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "Name,Price,DishCategoryID")] Dish dish)
 {
     if (AuthenticationTools.UserHasRole(currentUserName, "StaffMember,Boss,Admin"))
     {
         if (ModelState.IsValid)
         {
             db.Entry(dish).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.DishCategoryID = new SelectList(db.DishCategories, "ID", "Name", dish.DishCategoryID);
         return(View(dish));
     }
     return(RedirectToAction("Login", "Account"));
 }
Exemplo n.º 8
0
 // GET: Dishes/Details/5
 public ActionResult Details(int?id)
 {
     if (AuthenticationTools.UserHasRole(currentUserName, "StaffMember,Boss,Admin"))
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Dish dish = db.Dishes.Find(id);
         if (dish == null)
         {
             return(HttpNotFound());
         }
         return(View(dish));
     }
     return(RedirectToAction("Login", "Account"));
 }
Exemplo n.º 9
0
 // GET: Dishes/Edit/5
 public ActionResult Edit(int?id)
 {
     if (AuthenticationTools.UserHasRole(currentUserName, "StaffMember,Boss,Admin"))
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Dish dish = db.Dishes.Find(id);
         if (dish == null)
         {
             return(HttpNotFound());
         }
         ViewBag.DishCategoryID = new SelectList(db.DishCategories, "ID", "Name", dish.DishCategoryID);
         return(View(dish));
     }
     return(RedirectToAction("Login", "Account"));
 }
Exemplo n.º 10
0
        // GET: Companies/Details/5
        public ActionResult Details(int?id)
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Company company = db.Companies.Find(id);

            if (company == null)
            {
                return(HttpNotFound());
            }
            return(View(company));
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "Name,StatusID,LevelID")] Company company)
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                company.StatusID = 1;
                db.Companies.Add(company);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StatusID = new SelectList(db.States, "ID", "Name", company.StatusID);
            ViewBag.LevelID  = new SelectList(db.Levels, "ID", "Name", company.LevelID);

            return(View(company));
        }
Exemplo n.º 12
0
        public ActionResult Edit(Company company)
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                Company nc = db.Companies.Where(x => x.ID == company.ID).FirstOrDefault();
                nc.Name            = company.Name;
                nc.LevelID         = company.LevelID;
                db.Entry(nc).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.StatusID = new SelectList(db.States, "ID", "Name", company.StatusID);
            ViewBag.LevelID  = new SelectList(db.Levels, "ID", "Name", company.LevelID);

            return(View(company));
        }
Exemplo n.º 13
0
        // GET: Companies/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!AuthenticationTools.UserHasRole(currentUser, "Boss,Admin"))
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Company company = db.Companies.Find(id);

            if (company == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StatusID = new SelectList(db.States, "ID", "Name", company.StatusID);
            ViewBag.LevelID  = new SelectList(db.Levels, "ID", "Name", company.LevelID);

            return(View(company));
        }