Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Club
- {
- // Class to manage a single Club
- [Key]
- public int ClubID { get; set; }
- //Name
- [Required(ErrorMessage = "You must enter a Club Name")]
- [DataType(DataType.Text)]
- [StringLength(50, ErrorMessage = "Club Name cannot be longer than 50 characters")]
- [Display(Name = "Club Name")]
- public string ClubName { get; set; }
- //Discription
- [Display(Name = "Description")]
- [StringLength(200, ErrorMessage = "Discription is too long")] //character remaining count
- public string ClubDescription { get; set; }
- //Club Type
- public enum ClubType { Archery, Athletics, Basketball, Boxing, Camogie, Cricket, Cycling, Darts, Gaelic, Golf, Handball, Hocky, Hurling, Karate, MMA, Pool, Rugby, Snooker, Snowsports, Soccer, Surfing, Swimming, Tennis, Vollyball, Windsurfing, Youth, Other }
- //List of Members that are members of this Club
- public virtual List<ClubMember> ClubMembers { get; set; }
- //List of Events for this Club
- public virtual List<ClubEvent> ClubEvents { get; set; } //List of Events for this Club
- public String ClubImage { get; set; }
- }//end Club
- public class ClubMember
- {
- [Key]
- public int UserId { get; set; }
- //First Name
- [Required(ErrorMessage = "You must enter a First Name")]
- [StringLength(50, ErrorMessage = "You have used too many characters")] //character remaining count
- [DataType(DataType.Text)]
- [Display(Name = "First Name")]
- public string UserFName { get; set; }
- //Last Name
- [Required(ErrorMessage = "You must enter a Last Name")]
- [StringLength(50, ErrorMessage = "You have used too many characters")] //character remaining count
- [DataType(DataType.Text)]
- [Display(Name = "Last Name")]
- public string UserLName { get; set; }
- //User Name
- [Required(ErrorMessage = "You must enter a User Name")]
- [DataType(DataType.Text)]
- [Display(Name = "User Name")]
- public string UserName { get; set; }
- //Email
- [Required(ErrorMessage = "You must enter an Email Address")]
- [RegularExpression(@"^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$", ErrorMessage = "Please enter a valid email address")]
- [StringLength(50, ErrorMessage = "You have used too many characters")] //character remaining count
- [Display(Name = "Email")]
- public string UserEmail { get; set; }
- //Description
- [Display(Name = "User Description")]
- [StringLength(200, ErrorMessage = "You have used too many characters")] //character remaining count
- public string UserDescription { get; set; }
- //Date Of Brith
- [Required(ErrorMessage = "You must select your Date Of Birth")]
- [Display(Name = "Date of Birth")]
- public DateTime UserDoB { get; set; }
- //Image
- public string UserImage { get; set; }
- //Password
- //[Required]
- [StringLength(20, MinimumLength = 6)]
- public string UserPassword { get; set; }
- //Foreign Key for Club
- public int ClubID { get; set; }
- [ForeignKey("ClubID")]
- public virtual Club Club { get; set; }
- }//end User Class
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Club club = db.Clubs.Find(id);
- if (club == null)
- {
- return HttpNotFound();
- }
- return View(club);
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Edit([Bind(Include = "ClubID,ClubName,ClubDescription,ClubMembers")] Club club)
- {
- if (ModelState.IsValid)
- {
- db.Entry(club).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(club);
- }
- @model ultimateorganiser.Models.Club
- @{
- ViewBag.Title = "Edit";
- }
- <h2>Edit</h2>
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
- <div class="form-horizontal">
- <h4>Club</h4>
- <hr />
- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
- @Html.HiddenFor(model => model.ClubID)
- <div class="form-group">
- @Html.LabelFor(model => model.ClubName, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.ClubName, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.ClubName, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group">
- @Html.LabelFor(model => model.ClubDescription, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.ClubDescription, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.ClubDescription, "", new { @class = "text-danger" })
- </div>
- </div>
- @*This is where I want to display each club member in a list*@
- @foreach (var item in Model.ClubMembers)
- {
- <div class="form-group">
- @Html.LabelFor(model => model.ClubMembers, htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.ClubMembers, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.ClubMembers, "", new { @class = "text-danger" })
- </div>
- </div>
- }
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <input type="submit" value="Save" class="btn btn-default" />
- </div>
- </div>
- </div>
- }
- <div>
- @Html.ActionLink("Back to List", "Index")
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement