Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @using (Html.BeginForm("AddClub", "Club", FormMethod.Post, new { @class = "form-horizontal" }))
- {
- <div class="form-group">
- <label class="control-label col-sm-3">Club Sponser:</label>
- <div class="col-sm-4">
- @Html.TextBox("ClubSponser", null, new { @class = "form-control", id = "ClubSponser", placeholder = "Enter club Sponser" })
- </div>
- </div>
- <div class="btn-toolbar col-md-offset-7" role="group">
- <button type="submit" onsubmit="AddClub("ClubName","ClubOwner","ClubCoach","ClubSponser")" class="btn btn-primary">Add Club</button>
- <a href="@Url.Action("Index", "Home")" class="btn btn-danger">Cancel</a>
- </div>
- }
- [HttpPost]
- public ActionResult AddClub(string ClubName,string ClubOwner,string ClubCoach,string ClubSponser)
- {
- Club club = new Club()
- {
- Name = ClubName,
- Owner = ClubOwner,
- Coach=ClubCoach,
- Sponser=ClubSponser
- };
- clubRepo.AddClub(club);
- return RedirectToAction("Index","Club");
- }
- public async Task AddClub(Club club)
- {
- _context.Clubs.Add(club);
- await _context.SaveChangesAsync();
- }
- services.AddSingleton<IClubRepo, ClubService>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement