28 lines
887 B
C#
28 lines
887 B
C#
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.Linq;
|
|||
|
using System.Web.Mvc;
|
|||
|
using VideoGameQuotes.Api;
|
|||
|
|
|||
|
namespace VideoGameQuotes.Web.Models {
|
|||
|
public class CreateAdminModel {
|
|||
|
[DisplayName("Use existing user")]
|
|||
|
public int UserId { get; set; }
|
|||
|
public string Username { get; set; }
|
|||
|
[Required]
|
|||
|
public string Password { get; set; }
|
|||
|
|
|||
|
public IEnumerable<User> Users { get; set; }
|
|||
|
|
|||
|
public IEnumerable<SelectListItem> GetUserList() {
|
|||
|
return new[] { new SelectListItem { Text = "--none--", Value = "0" } }
|
|||
|
.Concat(Users
|
|||
|
.Where(user => user.Group != UserGroup.Admin)
|
|||
|
.OrderBy(user => user.Username)
|
|||
|
.ThenBy(user => user.IpAddress)
|
|||
|
.Select(user => new SelectListItem { Text = user.Username ?? user.IpAddress, Value = user.Id.ToString() })
|
|||
|
);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|