public async Task OnGetAsync() { SampleStorageExt.SampleId = int.Parse(RouteData.Values["handler"].ToString()); var tuple = await sampleConsignService.GetInitDataForSampleDetailPage(SampleStorageExt.SampleId.ToString(), null); SampleStorageExt.KindName = tuple.Item1; SampleStorageExt.ItemName = tuple.Item2; SampleStorageExt.SampleName = tuple.Item3; SampleStorageExt.Parameters = tuple.Item6.Select(x => tools.EntityCopy <ItemParameter, ItemParameterExt>(x)).ToList(); Specs = new SelectList(tuple.Item4, nameof(ItemSpec.SpecId), nameof(ItemSpec.SpecName), null, null); Grades = new SelectList(tuple.Item5, nameof(ItemGrade.GradeId), nameof(ItemGrade.GradeName), null, null); DelegateQuanUnit = new SelectList(tuple.Rest.Item1, nameof(DpDelegateQuanUnit.Nam), nameof(DpDelegateQuanUnit.Nam), null, null); var sampleUcName = tuple.Rest.Item2; var sampleucinfo = sampleUcControler.GetSampleUcViewComponentInfo(sampleUcName, SampleStorageExt.SampleId.ToString()); SampleStorageExt.SampleUcDbTableName = sampleucinfo.Item1;// the same as sampleuc table name SampleStorageExt.SampleUcViewComponentViewName = sampleucinfo.Item2; SampleDetailsPageCtl.IfShouldAddScript = sampleUcControler.GetIfShouldAddScript(sampleUcName, SampleStorageExt.SampleId.ToString()); SampleDetailsPageCtl.ShowSpecManual = Specs.Count() <= 0 ? ShowHideCssClass.show : ShowHideCssClass.hide; SampleDetailsPageCtl.ShowSpecSelect = Specs.Count() <= 0 ? ShowHideCssClass.hide : ShowHideCssClass.show; SampleDetailsPageCtl.ShowGradeManual = Grades.Count() <= 0 ? ShowHideCssClass.show : ShowHideCssClass.hide; SampleDetailsPageCtl.ShowGradeSelect = Grades.Count() <= 0 ? ShowHideCssClass.hide : ShowHideCssClass.show; SampleDetailsPageCtl.ShowProductorManual = tuple.Item7 ? ShowHideCssClass.show : ShowHideCssClass.hide; SampleDetailsPageCtl.ShowProductorSelect = tuple.Item7 ? ShowHideCssClass.hide : ShowHideCssClass.show; SampleDetailsPageCtl.ReadonlyProductorManual = tuple.Item7 ? ReadonlyCssClass.na : ReadonlyCssClass.ReadOnly; }
// // GET: /Account/Register public ActionResult Register() { if (!UzytkownikModel.SprawdzListeUzytkownikow()) { Uzytkownicy wlasciciel = UzytkownikModel.PobierzUzytkownikaPoLoginie(User.Identity.Name); if (wlasciciel != null && wlasciciel.RolaID == UzytkownikModel.ZwrocNrAdministratora()) { SelectList kodyPocztowe = new SelectList(KodyPocztoweModel.pobierzListeKodowPocztowych(), "KodPocztowyID", "Kod"); SelectList role = new SelectList(RoleModel.PobierzListeStawekVat(), "RolaID", "Nazwa"); if (kodyPocztowe.Count() == 0 || role.Count() == 0) { List <string> brakuje = new List <string>(); brakuje.Add("Kody pocztowe"); ViewData["Brakuje"] = brakuje; return(View("BladPostepowania")); } ViewData["KodyPocztowe"] = kodyPocztowe; ViewData["Role"] = role; return(View()); } else { return(View("BladRejestracjiAdmin")); } } else { UzytkownikModel.Pierwszy(); return(View("PierwszyUzytkownik")); } }
// // GET: /Towary/Edit/5 public ActionResult Edit(int id) { if (UzytkownikModel.PobierzUzytkownikaPoLoginie(User.Identity.Name) == null) { return(RedirectToAction("LogOn", "Account")); } TowaryUslugiRepozytorium towar = new TowaryUslugiRepozytorium(TowaryUslugiModel.PobierzTowarUsugePoID(id)); towar.cena = (decimal)towar.TowarUsluga.CenaNetto; towar.netto = true; if (towar.TowarUsluga.Rodzaj.Equals("Towar")) { towar.rodzaj = true; } else { towar.rodzaj = false; } SelectList stawkiVAT = new SelectList(StawkiVatModel.PobierzListeStawekVat(), "StawkaVatID", "Wartosc", towar.TowarUsluga.StawkaVatID); SelectList jednostkiMiar = new SelectList(JednostkiMiarModel.PobierzListeJednostekMiar(), "JednostkaMiarID", "Nazwa", towar.TowarUsluga.JednostkaMiarID); if (stawkiVAT.Count() == 0 || jednostkiMiar.Count() == 0) { return(View("BladPostepowania")); } else { ViewData["StawkiVAT"] = stawkiVAT; ViewData["JenostkiMiar"] = jednostkiMiar; return(View(towar)); } }
// GET: Avaliacaos/finalizarProva/5 public async Task <IActionResult> finalizarProva(int?id) { if (id == null) { return(NotFound()); } var avaliacao = await _context.Avaliacao.FindAsync(id); if (avaliacao == null) { return(NotFound()); } var amem = new SelectList(_context.Questoes.Where(a => a.AvaliacaoId == id).Select(a => a.AvaliacaoId).ToList()); var soma = new SelectList(_context.Questoes.Where(a => a.AvaliacaoId == id).Select(a => a.Valor).ToList()); ViewData["DisciplinaId"] = new SelectList(_context.Disciplina, "DisciplinaId", "NomeDisciplina", avaliacao.DisciplinaId); ViewData["ProfessorId"] = new SelectList(_context.Professor, "ProfessorId", "NomeProfessor", avaliacao.ProfessorId); ViewData["qtd_questoes"] = amem.Count(); //var contandoIsso = 0 ; //foreach (var somando in soma) //{ // Console.WriteLine(somando); //} //ViewData["soma_questoes"] = contandoIsso; return(View(avaliacao)); }
// // GET: /Odbiorcy/Create public ActionResult Create() { if (UzytkownikModel.PobierzUzytkownikaPoLoginie(User.Identity.Name) == null) { return(RedirectToAction("LogOn", "Account")); } SelectList kodPocztowy = new SelectList(KodyPocztoweModel.pobierzListeKodowPocztowych(), "KodPocztowyID", "Kod"); SelectList kodPocztowyKontakt = new SelectList(KodyPocztoweModel.pobierzListeKodowPocztowych(), "KodPocztowyID", "Kod"); if (kodPocztowy.Count() == 0) { System.Collections.Generic.List <string> brakuje = new System.Collections.Generic.List <string>(); brakuje.Add("Kody pocztowe"); ViewData["Brakuje"] = brakuje; return(View("BladPostepowania")); } else { ViewData["KodPocztowy"] = kodPocztowy; ViewData["KodPocztowyKontakt"] = kodPocztowyKontakt; return(View()); } }
public void CtorCreatesSameNumberOfElementsThanSource() { var model = new SelectModelTest(); var list = new SelectList(model.Countries, "Id", "Name"); Assert.AreEqual(model.Countries.Count(), list.Count()); }
public ActionResult AgregarLiberacion() { try { var zona = db.AC_Zona.ToList(); SelectList listzona = new SelectList(zona, "ID", "Nombre"); ViewBag.zona = listzona; var daño = db.AC_Daño.ToList(); SelectList listDaño = new SelectList(daño, "D_ID", "Nombre"); ViewBag.daño = listDaño; if (listzona.Count() == 0) { ViewBag.error = "No se puede agregar un animal todavia"; ViewBag.mensage = "Agregue una zona primero"; return(View("Error")); } else if (listDaño.Count() == 0) { ViewBag.error = "No se puede agregar un animal todavia"; ViewBag.mensage = "Agregue un daño primero"; return(View("Error")); } } catch (Exception ex) { ViewBag.mensage = "Error de Conexion"; } return(View()); }
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: Waybil/Create public ActionResult Create() { SelectList bus = new SelectList(waybilDAO.GetAllBus()); ViewBag.AllBus = bus; IEnumerable <Route> route = waybilDAO.GetAllRoute(); ViewBag.AllRoute = new SelectList(route, "id", "routeName"); IEnumerable <Driver> drivers = waybilDAO.GetAllDriver(); ViewBag.AllDriver = new SelectList(drivers, "personnelNumber", "LastName"); IEnumerable <Conductor> conductors = waybilDAO.GetAllConductor(); ViewBag.AllConductor = new SelectList(conductors, "personnelNumber", "LastName"); if (bus.Count() == 0) { return(View("ErrorBus")); } if (drivers.Count() == 0) { return(View("ErrorDriver")); } if (conductors.Count() == 0) { return(View("ErrorConductor")); } return(View()); }
public ActionResult AgregarControl_Diario() { var animal = db.AC_Animal.ToList(); SelectList listAnimal = new SelectList(animal, "ID", "Especie"); ViewBag.animal = listAnimal; var medicamento = db.AC_Medicamento.ToList(); SelectList listMedicamento = new SelectList(medicamento, "M_ID", "Nombre"); ViewBag.medicamento = listMedicamento; var vacuna = db.AC_Vacuna.ToList(); SelectList listaVacuna = new SelectList(vacuna, "ID", "Nombre"); ViewBag.vacunas = listaVacuna; if (listAnimal.Count() == 0) { ViewBag.error = "No se puede agregar un control todavia"; ViewBag.mensage = "Agregue un animal primero"; return(View("Error")); } else if (listaVacuna.Count() == 0) { ViewBag.error = "No se puede agregar un control todavia"; ViewBag.mensage = "Agregue una vacuna primero"; return(View("Error")); } else if (listMedicamento.Count() == 0) { ViewBag.error = "No se puede agregar un control todavia"; ViewBag.mensage = "Agregue un medicamento primero"; return(View("Error")); } return(View()); }
/// <summary> /// Performs standard Assertions to check that a Select List is passed to ViewData correctly /// </summary> /// <param name="viewData">The View Data that is expected to contain a Select List</param> /// <param name="viewDataKey">The key value to get the Select List from the View Data</param> /// <param name="expectedValues">The string values expected for the Select List values</param> /// <param name="selectedValue">The value that should be selected in the Select List by default. Null, if no default value</param> protected void AssertThatViewDataIsSelectList(ViewDataDictionary viewData, string viewDataKey, IQueryable <string> expectedValues, string selectedValue = null) { // Check viewData key is not null Assert.IsNotNull(viewData[viewDataKey], $"ViewData.{viewDataKey} should not be null"); // Check that all expected items are in list SelectList list = (SelectList)viewData[viewDataKey]; int expectedCount = expectedValues.Count(); Assert.AreEqual(expectedCount, list.Count(), "There are missing items in the select list"); // Check all items in list are correct string errorMsg = "The following IDs are missing from the Select List: "; int missingItems = 0; foreach (var item in expectedValues) { if (list.Where(i => i.Value == item.ToString()).FirstOrDefault() == null) { missingItems += 1; errorMsg += item.ToString() + ", "; } } errorMsg = errorMsg.Substring(0, errorMsg.Length - 2); Assert.AreEqual(0, missingItems, errorMsg); // Check that the correct item is pre-selected if (selectedValue != null) { bool isSelected = list.Where(i => i.Value == selectedValue).FirstOrDefault().Selected; Assert.IsTrue(isSelected, $"The SelectList item with value = '{selectedValue}' is not selected"); } }
public ActionResult Create() { if (UzytkownikModel.PobierzUzytkownikaPoLoginie(User.Identity.Name) == null) { return(RedirectToAction("LogOn", "Account")); } KontrahentKupnoModel kontrahenci = new KontrahentKupnoModel(); SelectList kontrahent = kontrahenci.dodajWszystkich(DostawcyModel.PobierzListeDostawcow()); SelectList t = new SelectList(TowaryUslugiModel.PobierzListTowarow(), "TowarID", "Nazwa"); SelectList FormaPlatnosc = new SelectList(FormyPlatnosciModel.PobierzListeFormPlatnosci(), "FormaPlatnosciID", "Nazwa"); if (FormaPlatnosc.Count() == 0 || kontrahent.Count() == 0 || t.Count() == 0) { System.Collections.Generic.List <string> brakuje = new System.Collections.Generic.List <string>(); brakuje.Add("Dostawcy"); brakuje.Add("Towary i usługi"); brakuje.Add("Formy płatności"); ViewData["Brakuje"] = brakuje; return(View("BladPostepowania")); } else { ViewData["FormyPlatnosci"] = FormaPlatnosc; ViewData["Kontrahenci"] = kontrahent; return(View(new DokumentyKupna())); } }
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)); }
// // GET: /Towary/Create public ActionResult Create() { if (UzytkownikModel.PobierzUzytkownikaPoLoginie(User.Identity.Name) == null) { return(RedirectToAction("LogOn", "Account")); } ; var TowarUsluga = new TowaryUslugiRepozytorium(); SelectList stawkiVAT = new SelectList(StawkiVatModel.PobierzListeStawekVat(), "StawkaVatID", "Wartosc"); SelectList jednostkiMiar = new SelectList(JednostkiMiarModel.PobierzListeJednostekMiar(), "JednostkaMiarID", "Nazwa"); if (stawkiVAT.Count() == 0 || jednostkiMiar.Count() == 0) { List <string> brakuje = new List <string>(); brakuje.Add("Stawki VAT"); brakuje.Add("Jednostki miar"); ViewData["Brakuje"] = brakuje; return(View("BladPostepowania")); } else { ViewData["StawkiVAT"] = stawkiVAT; ViewData["JenostkiMiar"] = jednostkiMiar; return(View(TowarUsluga)); } }
public ActionResult Register(Uzytkownicy uzytkownik, int Rola = 0, int KodPocztowy = 0) { if (ModelState.IsValid) { MembershipCreateStatus createStatus; if (KodPocztowy != 0) { Uzytkownicy wlasciciel = UzytkownikModel.PobierzUzytkownikaPoLoginie(User.Identity.Name); uzytkownik.WlascicielID = wlasciciel.UzytkownikID; uzytkownik.DataWprowadzenia = DateTime.Now; MojMembershipProvider.CreateUser(uzytkownik, KodPocztowy, Rola, out createStatus); if (createStatus == MembershipCreateStatus.Success) { return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } else { Rola = UzytkownikModel.ZwrocNrAdministratora(); MojMembershipProvider.CreateUser(uzytkownik, Rola, out createStatus); if (createStatus == MembershipCreateStatus.Success) { FormsAuthentication.SetAuthCookie(uzytkownik.Login, false /* createPersistentCookie */); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } } else if (KodPocztowy != 0) { // If we got this far, something failed, redisplay form SelectList kodyPocztowe = new SelectList(KodyPocztoweModel.pobierzListeKodowPocztowych(), "KodPocztowyID", "Kod"); SelectList role = new SelectList(RoleModel.PobierzListeStawekVat(), "RolaID", "Nazwa"); if (kodyPocztowe.Count() == 0 || role.Count() == 0) { return(View("Error")); } ViewData["KodyPocztowe"] = kodyPocztowe; ViewData["Role"] = role; return(View(uzytkownik)); } else { return(View("PierwszyUzytkownik")); } return(View(uzytkownik)); }
public void Edit_ReturnsSelectListOfGemeentenAndSelectedValue() { _brewerRepository.Setup(m => m.GetBy(1)).Returns(_dummyContext.Bavik); _locationRepository.Setup(m => m.GetAll()).Returns(_dummyContext.Locations); IActionResult action = _controller.Edit(1); ViewResult result = action as ViewResult; SelectList locationsInViewData = result?.ViewData["Locations"] as SelectList; Assert.Equal(3, locationsInViewData.Count()); }
public void CreateMustReturnSelectListOfGemeentenWithNoSelectedValue() { _locationRepository.Setup(m => m.GetAll()).Returns(_dummyContext.Locations); IActionResult action = _controller.Create(); ViewResult result = action as ViewResult; SelectList locationsInViewData = result?.ViewData["Locations"] as SelectList; Assert.Equal(3, locationsInViewData.Count()); Assert.Null(locationsInViewData?.SelectedValue); }
public void EditShouldReturnSelectListOfCategories() { _mockProductRepository.Setup(p => p.GetById(4)).Returns(_dummyContext.RunningShoes); _mockCategoryRepository.Setup(c => c.GetAll()).Returns(_dummyContext.Categories); ViewResult result = _productController.Edit(_runningShoesId) as ViewResult; SelectList categories = result?.ViewData["Categories"] as SelectList; Assert.Equal(_dummyContext.Categories.Count(), categories.Count()); Assert.Equal(2, categories?.SelectedValue); }
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); }
private SelectList GetSelectList(SelectList selectList, object selectedItem) { if (selectList != null && selectList.Count() > 0) { return(selectedItem != null ? new SelectList(selectList.Items, selectList.DataValueField, selectList.DataTextField, selectedItem) : selectList); } else { return(null); } }
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); }
public ActionResult Create(Agent_ProgramClasification agent_ProgramClasification) { if (ModelState.IsValid) { var idcompany = Guid.Parse(Request.RequestContext.HttpContext.Session["Company"].ToString()); agent_ProgramClasification.idprogramclasification = Guid.NewGuid(); agent_ProgramClasification.Agent_Empresa = db.Agent_Empresa.Where(e => e.IdCompany == idcompany).SingleOrDefault(); db.Agent_ProgramClasification.Add(agent_ProgramClasification); db.SaveChanges(); Success("Registro creado con exito"); return(RedirectToAction("Index")); } Agent_ProgramClasification program_clasification = new Agent_ProgramClasification(); OperationController opc = new OperationController(); Guid icompany = Guid.Parse(Request.RequestContext.HttpContext.Session["Company"].ToString()); List <AutomaticTakeTimeModel> added = db.Agent_ProgramClasification.Where(r => r.Agent_Empresa.IdCompany == icompany).Select(t => new AutomaticTakeTimeModel { Application = t.name }).ToList(); List <AutomaticTakeTimeModel> programs = opc.GetSoftWareClasification(icompany.ToString()); program_clasification.AutomaticTakeTime = programs; List <SelectListItem> sli = new List <SelectListItem>(); foreach (var i in programs.OrderBy(o => o.Application)) { if (added.Where(t => t.Application == i.Application).Count() <= 0) { SelectListItem si = new SelectListItem(); si.Text = i.Application; si.Value = i.Application; if (agent_ProgramClasification.name == i.Application) { si.Selected = true; } sli.Add(si); } } SelectList sl = new SelectList(sli); if (sl.Count() <= 0) { ViewBag.noprograms = "Ya no hay mas programas para clasificar"; } ViewBag.name = sl.Items; return(View(agent_ProgramClasification)); }
public void CreateSelectsEditViewWhenModelStateContainsErrors() { _locationRepository.Setup(m => m.GetAll()).Returns(_dummyContext.Locations); EditViewModel newBrewerEvm = new EditViewModel(new Brewer()); _controller.ModelState.AddModelError("", "Error message"); ViewResult result = _controller.Create(newBrewerEvm) as ViewResult; SelectList locationsInViewData = result?.ViewData["Locations"] as SelectList; Assert.Equal(newBrewerEvm, result?.Model); Assert.Equal(3, locationsInViewData.Count()); }
/// <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; } }
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); }
// GET: News/Create public ActionResult Create() { SelectList list = new SelectList(db.Categories, "ID", "Name"); // Caso não existam categorias, não deixa criar uma noticia if (list.Count() == 0) { return(RedirectToAction("Index", "UserError", new { error = "You can't create a News Article.", details = "There are no categories created." })); } ViewBag.CategoryFK = list; return(View()); }
public async Task <IActionResult> CreateInvoice() { var stores = new SelectList(await _StoreRepository.GetStoresByUserId(GetUserId()), nameof(StoreData.Id), nameof(StoreData.StoreName), null); if (stores.Count() == 0) { StatusMessage = "Error: You need to create at least one store before creating a transaction"; return(RedirectToAction(nameof(UserStoresController.ListStores), "UserStores")); } return(View(new CreateInvoiceModel() { Stores = stores })); }
public static MvcHtmlString Custom_GenderDropDownFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string name, SelectList values, Object htmlAttributes) { //Razor html example (Edit): //@Html.Custom_GenderDropDownFor(model => model.Tblguests.gGender, "gGender", new SelectList(new List<SelectListItem> { new SelectListItem { Text = Model.Tblguests.gGender, Value = Model.Tblguests.gGender } }, "Value", "Text"), new { @class = "form-control" }) List <SelectListItem> selItems = new List <SelectListItem>(); int valCount = values.Count(); string nameval = ""; if (valCount == 1) { foreach (var item in values) { nameval = item.Value; } } if (nameval.ToLower() == "f") { selItems.Add(new SelectListItem() { Text = "Female", Value = "F", Selected = true }); selItems.Add(new SelectListItem() { Text = "Male", Value = "M", Selected = false }); } else { selItems.Add(new SelectListItem() { Text = "Female", Value = "F", Selected = false }); selItems.Add(new SelectListItem() { Text = "Male", Value = "M", Selected = true }); } //return Custom_GenderDropDown(helper, expression, values, htmlAttributes); //return Custom_GenderDropDown(helper, expression, name, new SelectList(selItems), htmlAttributes); //return SelectExtensions.DropDownList(helper, // name, // selItems, // htmlAttributes); return(SelectExtensions.DropDownListFor(helper, expression, selItems, htmlAttributes)); }
public ActionResult Edit(int?id) { var selectListItems = new SelectList(_plataformaService.GetAll(), "PlataformaId", "Nome").ToList(); selectListItems.Insert(selectListItems.Count(), new SelectListItem { Text = "Outros", Value = "99999" }); ViewBag.PlataformaId = selectListItems; var retorno = new PlataformaSenha(); retorno.Senha = id.HasValue ? _senhasService.GetById((int)id) : null; return(PartialView("_EditPartial", retorno)); }
public async Task <IActionResult> CreateInvoice() { var stores = new SelectList(await _StoreRepository.GetStoresByUserId(GetUserId()), nameof(StoreData.Id), nameof(StoreData.StoreName), null); if (stores.Count() == 0) { TempData[WellKnownTempData.ErrorMessage] = "You need to create at least one store before creating a transaction"; return(RedirectToAction(nameof(UserStoresController.ListStores), "UserStores")); } return(View(new CreateInvoiceModel() { Stores = stores, AvailablePaymentMethods = GetPaymentMethodsSelectList() })); }