Exemplo n.º 1
0
        public void GetStore(userCompany userCompany = null)
        {
            var stores = db.store.Where(s => !s.DeletionDatetime.HasValue && s.company.DeletionDatetime == null);

            if (!new CuponeraPrincipal(new CuponeraIdentity(User.Identity)).IsInRole("admin"))
            {
                if (CuponeraIdentity.AdminCompany > 0)
                {
                    stores = stores.Where(s => CuponeraIdentity.AdminCompany == s.IdCompany);
                }
                else
                {
                    stores = stores.Where(s => CuponeraPrincipal.CanAdminStore(s.IdStore));
                }
            }

            if (userCompany != null)
            {
                ViewBag.IdStore = new SelectList(stores, "IdStore", "Name", userCompany.IdCompany);
            }
            else
            {
                ViewBag.IdStore = new SelectList(stores, "IdStore", "Name");
            }
        }
Exemplo n.º 2
0
        public void GetCompany(userCompany userCompany=null)
        {
            var companies = db.company.Where(c => !c.DeletionDatetime.HasValue);

            if (!new CuponeraPrincipal(new CuponeraIdentity(User.Identity)).IsInRole("admin"))
            {
                if (CuponeraIdentity.AdminCompany > 0)
                {
                    companies = companies.Where(c => CuponeraIdentity.AdminCompany == c.IdCompany);
                }
                else
                {
                    companies = db.store.Where(s => CuponeraPrincipal.CanAdminStore(s.IdStore)).Select(s => s.company);
                }
            }

            if (userCompany != null)
            {
                ViewBag.IdCompany = new SelectList(companies, "IdCompany", "Name", userCompany.IdCompany);
            }
            else
            {
                ViewBag.IdCompany = new SelectList(companies, "IdCompany", "Name");
            }
        }