Example #1
0
        public void TestToSelectList()
        {
            Dictionary <int, string> dict = new Dictionary <int, string> {
                { 1, "A" }, { 2, "B" }
            };

            SelectList sl = dict.ToSelectList(kvp => kvp.Key, kvp => kvp.Value);

            Assert.AreEqual(sl.First().Text, "A");
            Assert.AreEqual(sl.First().Value, "1");
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,ParentId,Description")] Specialty specialty)
        {
            if (specialty.ParentId == 0)
            {
                specialty.ParentId = null;
            }
            if (ModelState.IsValid)
            {
                db.Entry(specialty).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            var specialties = new SelectList(db.Specialties.Where(x => x.ParentId == null), "Id", "Title").ToList();

            specialties.Insert(0, new SelectListItem()
            {
                Text = "هیچکدام", Value = "0"
            });
            if (specialty?.ParentId != null)
            {
                specialties.First(x => x.Value == specialty.ParentId.ToString()).Selected = true;
            }
            ViewBag.ParentId = specialties;
            return(View(specialty));
        }
        public async Task <IActionResult> Program(int?id = null)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage != PsSchedulingStage.RegistrationOpen)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var userId    = GetId(ClaimType.UserId);
            var performer = await _performerSchedulingService.GetPerformerByUserIdAsync(userId);

            if (performer == null)
            {
                return(RedirectToAction(nameof(Information)));
            }
            else if (!performer.SetSchedule)
            {
                return(RedirectToAction(nameof(Schedule)));
            }

            var ageGroups = await _performerSchedulingService.GetAgeGroupsAsync();

            var ageList = new SelectList(ageGroups, "Id", "Name");

            if (ageList.Count() == 1)
            {
                ageList.First().Selected = true;
            }

            var viewModel = new ProgramViewModel
            {
                AgeList               = ageList,
                MaxUploadMB           = MaxUploadMB,
                RegistrationCompleted = performer.RegistrationCompleted,
                SetupSupplementalText = settings.SetupSupplementalText
            };

            if (id.HasValue)
            {
                try
                {
                    var program = await _performerSchedulingService.GetProgramByIdAsync(id.Value,
                                                                                        includeAgeGroups : true);

                    viewModel.AgeSelection   = program.AgeGroups.Select(_ => _.Id).ToList();
                    viewModel.EditingProgram = true;
                    viewModel.Program        = program;
                }
                catch (GraException gex)
                {
                    ShowAlertDanger("Unable to view Program: ", gex);
                    return(RedirectToAction(nameof(Dashboard)));
                }
            }

            return(View(viewModel));
        }
Example #4
0
        // GET: Categories
        public async Task <IActionResult> Index()
        {
            int        IdEnterprise = int.Parse(User.Claims.ToList()[1].Value);
            Enterprise Enterprise   = _context.Enterprises.Find(IdEnterprise);
            string     NameCategory = "baseCategory." + Enterprise.Name;
            var        listCateg    = new SelectList(_context.Categories.Where(p => p.EnterpriseId == IdEnterprise), "Id", "Name");

            listCateg.First(p => p.Text == NameCategory).Text = "--Select--";
            ViewBag.ParCateg = listCateg;
            var productContext = _context.Categories.Where(p => p.EnterpriseId == IdEnterprise && p.Name != NameCategory);
            var list           = await productContext.ToListAsync();

            var listik = list.Where(p => p.ParentCategory.Name == NameCategory);

            foreach (var el in listik)
            {
                el.ParentCategory.Name = "";
            }



            ViewBag.category = new Category();
            HttpContext.Session.SetString("cater", "tty");
            return(View(list));
        }
        public ActionResult ManageSiteCategories(string tenantTypeId)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(HttpNotFound());
            }
            var authorizer = DIContainer.Resolve <Authorizer>();

            pageResourceManager.InsertTitlePart("站点类别管理");

            List <TenantType>        managedTenantTypes = new List <TenantType>();
            IEnumerable <TenantType> allTenantTypes     = tenantTypeService.Gets(MultiTenantServiceKeys.Instance().SiteCategory());

            foreach (var tenantType in allTenantTypes)
            {
                if (authorizer.IsAdministrator(tenantType.ApplicationId))
                {
                    managedTenantTypes.Add(tenantType);
                }
            }
            SelectList tenantList = new SelectList(managedTenantTypes.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId);

            if (string.IsNullOrEmpty(tenantTypeId))
            {
                tenantTypeId = tenantList.First().Value;
            }
            IEnumerable <Category> categorys = categoryService.GetOwnerCategories(0, tenantTypeId);

            ViewData["tenantList"]   = tenantList;
            ViewData["tenantTypeId"] = tenantTypeId;
            return(View(categorys));
        }
Example #6
0
        public async Task <IActionResult> AddNewBankClient(BankClientViewModel model)
        {
            var validator            = new BankClientValidator();
            ValidationResult results = validator.Validate(model);

            if (results.IsValid)
            {
                var user = _mapper.Map <BankClient>(model);
                await _bankClientService.AddClientToDatabase(user);

                return(RedirectToAction("OpenBankClientList"));
            }

            var cities = await _cityService.GetAllCites();

            var countries = await _countryService.GetAllCountries();

            var selectedListCurrentCities      = new SelectList(cities, "Id", "Name");
            var selectedListCountries          = new SelectList(countries, "Id", "Name");
            var selectedListRegistrationCities = new SelectList(cities, "Id", "Name");

            selectedListCurrentCities.First().Selected      = true;
            selectedListCountries.First().Selected          = true;
            selectedListRegistrationCities.First().Selected = true;
            ViewBag.PlaceOfLiving       = selectedListCurrentCities;
            ViewBag.PlaceOfRegistration = selectedListRegistrationCities;
            ViewBag.Citizenship         = selectedListCountries;
            model.Errors = results.Errors.Select((item) => item.ErrorMessage).ToList();
            return(View(model));
        }
        public async Task OnGetAsync(string returnUrl, string organisationType)
        {
            try
            {
                await SetViewData();

                OrganisationTypes    = new SelectList(await NodeContext.Org_tbTypes.OrderBy(t => t.OrganisationTypeCode).Select(t => t.OrganisationType).ToListAsync());
                OrganisationStatuses = new SelectList(await NodeContext.Org_tbStatuses.OrderBy(t => t.OrganisationStatusCode).Select(t => t.OrganisationStatus).ToListAsync());
                TaxCodes             = new SelectList(await NodeContext.App_TaxCodes.OrderBy(t => t.TaxCode).Select(t => t.TaxCode).ToListAsync());

                Orgs orgs = new(NodeContext);

                string organisatonType = string.IsNullOrEmpty(organisationType) ? OrganisationTypes.First().ToString()
                                        : await NodeContext.Org_tbTypes.Where(t => t.OrganisationType == organisationType).Select(t => t.OrganisationType).FirstOrDefaultAsync();

                OrgEntry = new OrgData()
                {
                    AccountName        = string.Empty,
                    OrganisationType   = organisationType,
                    OrganisationStatus = NodeContext.Org_tbStatuses.Where(t => t.OrganisationStatusCode == (short)NodeEnum.OrgStatus.Active).Select(t => t.OrganisationStatus).First(),
                    TaxCode            = await orgs.DefaultTaxCode()
                };

                ReturnUrl = string.IsNullOrEmpty(returnUrl) ? "./Index" : returnUrl;
            }
            catch (Exception e)
            {
                NodeContext.ErrorLog(e);
                throw;
            }
        }
Example #8
0
        public async Task QueryReturnsCorrectCommand(SliceFixture fixture)
        {
            var category1 = new Category()
            {
                Name = "Category1"
            };
            var category2 = new Category()
            {
                Name = "Category2"
            };

            await fixture.InsertAsync(category1, category2);

            var query = new Create.Query();

            var command = await fixture.SendAsync(query);

            var categoriesInDb = new SelectList(await fixture
                                                .ExecuteDbContextAsync(db => db
                                                                       .Categories
                                                                       .Select(c => c.Name)
                                                                       .ToListAsync()));

            command.Categories.Count().ShouldBe(categoriesInDb.Count());
            command.Categories.First().Value.ShouldBe(categoriesInDb.First().Value);
            command.Categories.Skip(1).First().Value.ShouldBe(categoriesInDb.Skip(1).First().Value);
        }
        // GET: Admin/Specialties/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Specialty specialty = await db.Specialties.FindAsync(id);

            if (specialty == null)
            {
                return(HttpNotFound());
            }
            var specialties = new SelectList(db.Specialties.Where(x => x.ParentId == null), "Id", "Title").ToList();

            specialties.Insert(0, new SelectListItem()
            {
                Text = "هیچکدام", Value = "0"
            });
            if (specialty?.ParentId != null)
            {
                specialties.First(x => x.Value == specialty.ParentId.ToString()).Selected = true;
            }
            ViewBag.ParentId = specialties;
            return(View(specialty));
        }
Example #10
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                HardwareVault = await HardwareVaultService.GetVaultByIdAsync(HardwareVaultId);

                if (HardwareVault == null)
                {
                    throw new Exception("HardwareVault not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(HardwareVault.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(HardwareVault.Id, HardwareVault);
                }

                VaultProfiles          = new SelectList(await HardwareVaultService.GetProfilesAsync(), nameof(HardwareVaultProfile.Id), nameof(HardwareVaultProfile.Name));
                SelectedVaultProfileId = VaultProfiles.First().Value;

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
        // GET: Registar2/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblZivotinja zivotinja = db.tblZivotinja.Find(id);

            if (zivotinja == null)
            {
                return(HttpNotFound());
            }
            ViewBag.GovedoID         = new SelectList(db.tblGovedo, "GovedoID", "Ime", zivotinja.GovedoID);
            ViewBag.PosjednikID      = new SelectList(db.tblPosjednik, "PosjednikID", "Email", zivotinja.PosjednikID);
            ViewBag.VrstaZivotinjeID = new SelectList(db.tblVrstaZivotinje, "VrstaZivotinjeID", "Naziv", zivotinja.VrstaZivotinjeID);

            var selected = spolovi.First(x => x.Text == zivotinja.tblGovedo.Spol);

            selected.Selected = true;
            var sl = new SelectList(spolovi, selected.Text);

            ViewBag.Spolovi = sl;

            return(View(zivotinja));
        }
        public IActionResult Index(int?id, string algs)
        {
            ViewBag.userName    = HttpContext.Session.GetString("UserName");
            ViewBag.isDashboard = true;
            Memory memory;
            int    simulationSelected = 0;

            if (id != null)
            {
                memory = _context.Memories.Find(id);

                if (memory == null)
                {
                    return(RedirectToAction("Error404", "Erros"));
                }

                if (memory.UserID != HttpContext.Session.GetInt32("UserID"))
                {
                    return(RedirectToAction("Error403", "Erros"));
                }

                simulationSelected = memory.SimulationID;
            }

            var simulacoes = _context.Simulations.
                             Where(s => s.UserID == HttpContext.Session.GetInt32("UserID")).
                             OrderByDescending(s => s.CreateDate).ToList();

            SelectList simulations = new SelectList(simulacoes, "ID", "Name");

            if (simulacoes.Count() > 0)
            {
                var selected = simulations.First();
                selected.Selected = true;
            }

            ViewBag.SimulationID = simulations;

            if (id != null)
            {
                ViewBag.MemorySelected     = id;
                ViewBag.SimulationSelected = simulationSelected;
            }

            if (algs != null)
            {
                if (algs != "all" && algs != "first" && algs != "next" && algs != "best" && algs != "worst")
                {
                    return(RedirectToAction("Error404", "Erros"));
                }
            }
            else
            {
                algs = "all";
            }

            ViewBag.Algs = algs;

            return(View());
        }
        public IActionResult Create()
        {
            var countries = new SelectList(db.Countries.Select(c => new { c.Id, c.Name }).ToList(), "Id", "Name");

            int countryId = Convert.ToInt32(countries.First().Value);

            var regions = new SelectList(db.Regions
                                         .Where(r => r.Country.Id == countryId)
                                         .Select(c => new { Id = c.Id, Name = c.Name }).ToList(), "Id", "Name");

            int regionId = Convert.ToInt32(regions.First().Value);

            var cities = new SelectList(db.Cities
                                        .Where(c => c.Region.Id == regionId)
                                        .Select(c => new { Id = c.Id, Name = c.Name }).ToList(), "Id", "Name");

            int cityId = Convert.ToInt32(cities.First().Value);

            var streets = new SelectList(db.Streets
                                         .Where(s => s.City.Id == cityId)
                                         .Select(s => new { Id = s.Id, Name = s.Name }).ToList(), "Id", "Name");

            var viewModel = new AddressViewModel
            {
                Countries = countries,
                Regions   = regions,
                Cities    = cities,
                Streets   = streets
            };

            return(View(viewModel));
        }
Example #14
0
        public void testRolesSelect()
        {
            IMembershipRepository m = new MembershipRepository();

            SelectList sl = new SelectList(m.getAllRoles());

            Assert.AreEqual(sl.First().Text, "hello");
        }
        // GET: Pedidos
        public ActionResult Index(int?Estado, int?Page)
        {
            const int PedidosPorPagina = 10;

            if (Page == null)
            {
                Page = 1;
            }
            IQueryable <Estados_Pedido> EstadosPedidoConsulta = db.Estados_Pedido;
            IEnumerable <Pedidos>       Pedidos;

            if (User.IsInRole("Administrador"))
            {
                Pedidos = db.Pedidos;
            }
            else
            {
                string   NombreUsuario = User.Identity.GetUserName();
                Clientes Cliente       = db.Clientes.Where(e => e.Email == NombreUsuario).FirstOrDefault();
                if (Cliente == null)
                {
                    return(RedirectToAction("Create", "Clientes"));
                }
                else
                {
                    Pedidos = Cliente.Pedidos.Where(e => e.Id_Estado > 1);
                    EstadosPedidoConsulta = EstadosPedidoConsulta.Where(e => e.Id != 1);
                    if (Estado == 1)
                    {
                        Estado = 0; // No permitimos que solicite los pedidos sin confirmar
                    }
                }
            }
            List <Estados_Pedido> EstadosPedidoLista = EstadosPedidoConsulta.ToList();

            EstadosPedidoLista.Insert(0, new Estados_Pedido {
                Id     = 0,
                Nombre = "[Todos]",
            });
            SelectList     EstadosPedido      = new SelectList(EstadosPedidoLista, "Id", "Nombre");
            SelectListItem EstadoSeleccionado = EstadosPedido.First();

            if (Estado != null)
            {
                Estados_Pedido EstadoPedidos = db.Estados_Pedido.Find(Estado);
                if (EstadoPedidos != null)
                {
                    Pedidos            = Pedidos.Where(e => e.Id_Estado == Estado);
                    EstadoSeleccionado = EstadosPedido.Where(e => e.Value == EstadoPedidos.Id.ToString()).First();
                }
            }
            EstadoSeleccionado.Selected      = true;
            ViewBag.EstadoSeleccionadoFiltro = EstadoSeleccionado;
            ViewBag.EstadosPedidos           = EstadosPedido.ToList();
            return(View(Pedidos.OrderByDescending(e => e.Fecha_Modificacion).ToPagedList((int)Page, PedidosPorPagina)));
        }
        public SelectList getStrmsList(string strm_code)
        {
            var res = _conntext.VUMM_HH_STRMS_USERS.Where(w => w.USER_NAME == User.Identity.Name && w.STRM_CODE != strm_code);
            var sl  = new SelectList(res, "strm_code", "strm_name", strm_code);

            if (sl.Count() == 1)
            {
                sl.First().Selected = true;
            }
            return(sl);
        }
        public IActionResult Index()
        {
            var currencies = _currencyDbContext.ExchangeRates.Select(x => x.Currency).Distinct().OrderBy(x => x);

            var sl = new SelectList(currencies);

            sl.First(x => x.Text == "EUR").Selected = true;

            ViewData["SelectList"] = sl;
            return(View());
        }
Example #18
0
        // GET: Categories/Create
        public IActionResult Create()
        {
            int        IdEnterprise = int.Parse(User.Claims.ToList()[1].Value);
            Enterprise Enterprise   = _context.Enterprises.Find(IdEnterprise);
            string     NameCategory = "baseCategory." + Enterprise.Name;
            var        list         = new SelectList(_context.Categories.Where(p => p.EnterpriseId == IdEnterprise), "Id", "Name");

            list.First(p => p.Text == NameCategory).Text = "--Select--";
            ViewData["ParentCategoryId"] = list;
            return(View());
        }
Example #19
0
        /// <summary>
        /// 相册下拉框
        /// </summary>
        private void GetAlbumList(long albumId)
        {
            IEnumerable <Album> albums    = photoService.GetUserAlbums(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(Url.SpaceKey()), true, SortBy_Album.DisplayOrder, 10000, 1).AsEnumerable <Album>();
            SelectList          albumList = new SelectList(albums.Select(n => new { text = n.AlbumName, value = n.AlbumId }), "value", "text", albumId);

            ViewData["albumList"] = albumList;
            ViewData["albumId"]   = albumId;
            if (albumId == 0 && albumList.Count() > 0)
            {
                ViewData["albumId"] = albumList.First().Value;
            }
        }
Example #20
0
 public ViewResult AddTourInfo()
 {
     ViewBag.Countries  = Countries;
     ViewBag.TourOpers  = TourOpers;
     ViewBag.Transport  = Transport;
     ViewBag.HotelNames = new SelectList(from hotel in db.Hotels
                                         join city in db.Cities on hotel.CityID equals city.CityID
                                         join country in db.Countries on city.CountryID equals country.CountryID
                                         where country.CountryName == Countries.First().Text
                                         select hotel.HotelName);
     return(View("AddTour"));
 }
Example #21
0
        public void DepartmentDropDownList_Default_AllDepartments()
        {
            //Arrange

            //Act
            SelectList result = controller.DepartmentDropDownList();

            //Assert
            Assert.AreEqual(7, result.Count());
            Assert.AreEqual("RAAA1", result.First().Text);
            Assert.AreEqual("TAAAA", result.Last().Text);
        }
Example #22
0
        public async Task QueryReturnsCorrectCommand(SliceFixture fixture)
        {
            // Arrange
            var category = new Category()
            {
                Name = "Category1"
            };
            var secondCategory = new Category()
            {
                Name = "Category2"
            };

            await fixture.InsertAsync(category, secondCategory);

            var createCommand = new Create.Command
            {
                Name        = "Product",
                Description = "Description",
                Price       = 12.00m,
                Category    = category,
            };

            await fixture.SendAsync(createCommand);

            var product = await fixture
                          .ExecuteDbContextAsync(db => db
                                                 .Products
                                                 .Include(p => p.Category)
                                                 .FirstOrDefaultAsync(p => p.Name == createCommand.Name));

            // Act
            var query = new Edit.Query()
            {
                ProductId = product.Id
            };
            var command = await fixture.SendAsync(query);

            // Assert
            var categoriesInDb = new SelectList(await fixture
                                                .ExecuteDbContextAsync(db => db
                                                                       .Categories
                                                                       .Select(c => c.Name)
                                                                       .ToListAsync()));

            command.Name.ShouldBe(product.Name);
            command.Description.ShouldBe(product.Description);
            command.Price.ShouldBe(product.Price);
            command.Category.Name.ShouldBe(product.Category.Name);
            command.Categories.Count().ShouldBe(categoriesInDb.Count());
            command.Categories.First().Value.ShouldBe(categoriesInDb.First().Value);
            command.Categories.Skip(1).First().Value.ShouldBe(categoriesInDb.Skip(1).First().Value);
        }
        public async Task PageSetup()
        {
            Rooms = await _roomService.GetAll();

            Speakers = await _speakerService.GetAll();

            Rooms.Insert(0, new Room {
                Name = "Vælg et lokale"
            });
            Speakers.Insert(0, new Speaker {
                FirstName = "Vælg en taler"
            });

            SelectListRooms    = new SelectList(Rooms.FindAll(room => room.VenueId.Equals(1) || room.VenueId == 0), nameof(Room.RoomId), nameof(Room.Name));
            SelectListSpeakers = new SelectList(Speakers, nameof(Speaker.SpeakerId), nameof(Speaker.FullName));

            SelectListRooms.First().Disabled    = true;
            SelectListSpeakers.First().Disabled = true;

            SelectListRooms.First().Selected    = true;
            SelectListSpeakers.First().Selected = true;
        }
Example #24
0
        public void testAllCommittees()
        {
            IGenericRepository    generic = new GenericRepository();
            IMeetingLibRepository mlib    = new MeetingLibRepository();
            // IList<TblMeetingLib> coms = generic.getAllMeetings();

            //IList<SelectItems> items = generic.getAllCommitteesSelect();

            IList <SelectItems> items = generic.getAllMeetingsSelect();

            IList <MeetingLib> itemsm = mlib.getAllMeetingLibs();
            SelectList         sl     = new SelectList(itemsm, "MeetingLibID", "MeetingLibDesc");

            Assert.AreEqual(sl.First().Text, "hello");
        }
        public void YearDropDownList_Default_AllYearList()
        {
            //Arrange
            List <int> yearList = (from holidays in mock.Object.Holidays
                                   select holidays.HolidayDate.Year).Distinct().ToList();

            //Act
            SelectList result = controller.YearDropDownList();

            //Assert
            Assert.AreEqual(yearList, result.Items);
            Assert.AreEqual(2, result.Count());
            Assert.AreEqual(2014, result.SelectedValue);
            Assert.AreEqual("2013", result.First().Text);
            Assert.AreEqual("2014", result.Last().Text);
        }
        public void CountryDropDownList_Default_ListofAllCountries()
        {
            //Arrange
            List <Country> countryList = (from countries in mock.Object.Countries
                                          select countries).ToList();

            //Act
            SelectList result = controller.CountryDropDownList();

            //Assert
            Assert.AreEqual(countryList, result.Items);
            Assert.AreEqual(5, result.Count());
            Assert.AreEqual(1, result.SelectedValue);
            Assert.AreEqual("Ukraine", result.First().Text);
            Assert.AreEqual("Zimbabve", result.Last().Text);
        }
        public ActionResult Edit()
        {
            var userDb         = this.users.GetById(this.User.Identity.GetUserId());
            var editRegisterVm = this.Mapper.Map <EditProfileViewModel>(userDb);
            var userTownId     = userDb.Address.Neighborhood.TownId;
            var townsItems     = new SelectList(this.towns.GetAll().ToList(), "Id", "Name");

            townsItems.First(t => t.Value == userTownId.ToString()).Selected = true;
            editRegisterVm.Towns = townsItems;
            var neighborhoodsItems = new SelectList(this.towns.GetTownNeigborhoods(userTownId).ToList(), "Id", "Name");

            neighborhoodsItems.First(n => n.Value == userDb.Address.NeighborhoodId.ToString()).Selected = true;
            editRegisterVm.Neighborhoods = neighborhoodsItems;

            return(this.PartialView("_EditPartialView", editRegisterVm));
        }
Example #28
0
        // GET: Products
        public async Task <IActionResult> Index(Product product1 = null)
        {
            int        IdEnterprise = int.Parse(User.Claims.ToList()[1].Value);
            Enterprise Enterprise   = _context.Enterprises.Find(IdEnterprise);
            string     NameCategory = "baseCategory." + Enterprise.Name;
            var        pp           = _context.Products.Where(p => p.ParCategory.ParentCategory.EnterpriseId == IdEnterprise);
            string     rrr          = HttpContext.Session.GetString("cater");

            var listCateg = new SelectList(_context.Categories.Where(p => p.EnterpriseId == IdEnterprise), "Id", "Name");

            listCateg.First(p => p.Text == NameCategory).Text = "--Select--";
            ViewBag.Category = listCateg;

            ViewBag.product = product1;
            return(View(await pp.ToListAsync()));
        }
Example #29
0
        public ActionResult EditTag(long tagId = 0)
        {
            TagService   tagService   = new TagService(string.Empty);
            TagEditModel tagEditModel = null;

            //创建
            if (tagId == 0)
            {
                tagEditModel = new TagEditModel();
                ViewData["seletedTagNames"] = new List <string>();

                //所属租户类型下拉框
                SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), null);
                ViewData["tenants"] = tenants;

                //标签分组下拉框
                SelectList tagGroups = GetTagGroupSelectList(0, tenants.First().Value);
                ViewData["tagGroups"] = tagGroups;

                ViewData["editTagTitle"] = "创建标签";

                pageResourceManager.InsertTitlePart("添加标签");
            }//编辑
            else
            {
                Tag tag = tagService.Get(tagId);
                tagEditModel = tag.AsTagEditModel();

                //所属租户类型下拉框
                SelectList tenants = GetTenantSelectList(MultiTenantServiceKeys.Instance().Tag(), tagEditModel.TenantTypeId);
                ViewData["tenants"] = tenants;

                //标签分组下拉框
                SelectList tagGroups = GetTagGroupSelectList(tagEditModel.GroupId, tagEditModel.TenantTypeId);
                ViewData["tagGroups"] = tagGroups;

                //取相关标签
                IEnumerable <string> seletedTagNames = tagService.GetRelatedTags(tagId).Select(n => n.TagName);
                ViewData["seletedTagNames"] = seletedTagNames;

                ViewData["editTagTitle"] = "编辑标签";

                pageResourceManager.InsertTitlePart("编辑标签");
            }

            return(View(tagEditModel));
        }
        /// <summary>
        /// viewBag contains
        /// 1. role list
        /// 2. firstMenu in role
        /// 3. secondMenu in role
        /// 4. thirdMenu in role
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> addMenu(string roleId = null)
        {
            Dictionary <string, string> dic = roleManager.Roles.ToDictionary(x => x.Id, x => x.Name);
            SelectList selectList           = new SelectList(dic, "Key", "Value", 0);

            ViewBag.DropDown = selectList;

            roleId = string.IsNullOrEmpty(roleId)? selectList.First().Value:roleId;
            RoleMenuEdit roleMenus = new RoleMenuEdit
            {
                role       = await roleManager.FindByIdAsync(roleId),
                firstDirs  = layer.searchRoleMenusNotInRoleId(roleId, DirLevel.FirstLevel),
                secondDirs = layer.searchRoleMenusNotInRoleId(roleId, DirLevel.SecondLevel),
            };

            return(View(roleMenus));
        }