public ActionResult Create() { // Create a view model object var accountDetails = new AccountDetails(); // Identity object "name" (i.e. not the claim) accountDetails.UserName = HttpContext.User.Identity.Name; // Work with the current User in claims-compatible mode var identity = User.Identity as ClaimsIdentity; // Now, go through the claims... // Get the name, if present //var name = identity.FindFirst(ClaimTypes.Name); //accountDetails.ClaimsName = name == null ? "(none)" : name.Value; // Get the given name, if present var givenName = identity.FindFirst(ClaimTypes.GivenName); accountDetails.ClaimsGivenName = givenName == null ? "(none)" : givenName.Value; // Get the surname, if present var surname = identity.FindFirst(ClaimTypes.Surname); accountDetails.ClaimsSurname = surname == null ? "(none)" : surname.Value; AlbumAddForm form = new AlbumAddForm(); form.Coordinator = givenName.Value + " " + surname.Value; form.GenreList = new SelectList(m.GenreGetAll(), "Name", "Name"); form.ArtistList = new MultiSelectList(m.ArtistGetAll(), dataValueField: "Id", dataTextField: "Name"); form.TrackList = new MultiSelectList(items: m.TarckGetAll(), dataValueField: "Id", dataTextField: "Name"); return(View(form)); }
public ActionResult AddAlbum(int?Id) { var form = new AlbumAddForm(); var a = m.ArtistGetByIdWithDetail(Id.GetValueOrDefault()); var values = new List <int> { a.Id }; form.KnownArtists = a.Name; form.GenreList = new SelectList (m.GenreGetAll(), "Id", "Name"); form.ArtistList = new MultiSelectList (items: m.ArtistGetAll(), dataValueField: "Id", dataTextField: "Name", selectedValues: values); form.TrackList = new MultiSelectList (items: m.TrackGetAll(), dataValueField: "Id", dataTextField: "Name"); return(View(form)); }
public ActionResult AddAlbum(int?id) { var a = m.ArtistWithDetailGetById(id.GetValueOrDefault()); if (a == null) { return(HttpNotFound()); } else { var o = new AlbumAddForm(); o.ArtistId = a.Id; o.ArtistName = a.Name; o.GenreList = new SelectList(m.GenreGetAll(), "Name", "Name"); o.ArtistList = new MultiSelectList (items: m.ArtistGetAll(), dataValueField: "Id", dataTextField: "Name", selectedValues: new List <int>() { id.GetValueOrDefault() } ); o.TrackList = new MultiSelectList (items: m.TrackGetAll(), dataValueField: "Id", dataTextField: "Name", selectedValues: null); return(View(o)); } }
// GET: Album/Create // Find a way to redirect to the Artist AddAlbum function. public ActionResult Create() { var form = new AlbumAddForm(); form.GenreList = new SelectList(m.GenreGetAll(), "Name", "Name"); return(View(form)); }
public ActionResult AddAlbum(int?id) { // Attempt to get the associated object var a = m.ArtistGetById(id.GetValueOrDefault()); if (a == null) { return(HttpNotFound()); } else { var o = new AlbumAddForm(); o.GenreList = new SelectList(m.GenreGetAll(), "Name", "Name"); o.ArtistId = a.Id; o.ArtistName = a.Name; return(View(o)); } }
public ActionResult Create(int?id) { var form = new AlbumAddForm(); form.ArtistList = new SelectList(items: m.ArtistGetAll(), dataValueField: "Id", dataTextField: "Name"); form.TrackList = new SelectList (items: m.TrackGetAll(), dataValueField: "Id", dataTextField: "Name"); form.GenreList = new SelectList (items: m.GenreGetAll(), dataValueField: "Name", dataTextField: "Name"); return(View(form)); }