public ActionResult Create([Bind(Include = "id,FirstName,LastName,shortname,Wheelchair")] Membership membership) { if (ModelState.IsValid) { _db.Memberships.Add(membership); try { _db.SaveChanges(); return(RedirectToAction("Index")); } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Insert failed"); } } return(View(membership)); }
public ActionResult Create([Bind(Include = "id,LeagueId,MembershipId")] Player player) { if (ModelState.IsValid) { _db.Players.Add(player); try { _db.SaveChanges(); return(RedirectToAction("Index", new { id = player.Leagueid })); } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Insert failed"); } } var list = GetRemainingMembers(player.Leagueid); list.Sort((a, b) => String.Compare(a.LastName + " " + a.FirstName, b.LastName + " " + b.FirstName, StringComparison.CurrentCulture)); ViewBag.List = list; return(View(player)); }
public ActionResult MoveUp(int id) { var match = _db.Matches.Find(id); if (match == null) { return(HttpNotFound()); } var weekMatches = _db.Matches.Where(x => x.WeekId == match.WeekId); var match1 = weekMatches.First(x => x.Rink == match.Rink - 1); match1.Rink = match.Rink; match.Rink = match1.Rink - 1; _db.Entry(match).State = EntityState.Modified; try { _db.SaveChanges(); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); throw; } return(RedirectToAction("Index", new { weekid = match.WeekId, id = match.Schedule.Leagueid })); }
public ActionResult Create([Bind(Include = "id,LeagueName,TeamSize,Active,TiesAllowed,PointsCount,WinPoints,TiePoints,ByePoints,StartWeek, PointsLimit")] League league) { if (ModelState.IsValid) { _db.Leagues.Add(league); try { _db.SaveChanges(); return(RedirectToAction("Index")); } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Insert failed"); } } return(View(league)); }
public ActionResult Create([Bind(Include = "id,Green,Direction,Boundary,rowversion")] RinkOrder rinkOrder) { if (ModelState.IsValid) { db.RinkOrders.Add(rinkOrder); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rinkOrder)); }
public ActionResult Create([Bind(Include = "id,FirstName,LastName,FullName,shortname,NickName,rowversion")] Membership membership) { if (ModelState.IsValid) { db.Memberships.Add(membership); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(membership)); }
public ActionResult Create([Bind(Include = "id,Skip,Lead,ViceSkip,TeamId,LeagueId,TeamNo")] Team team) { team.Skip = team.Skip == 0 ? (int?)null : team.Skip; team.ViceSkip = team.ViceSkip == 0 ? (int?)null : team.ViceSkip; team.Lead = team.Lead == 0 ? (int?)null : team.Lead; if (ModelState.IsValid) { _db.Teams.Add(team); try { if (CheckTeam(team)) { ModelState.AddModelError(string.Empty, "Unable to create record, a player cannot be on a team in multiple positions"); } else { _db.SaveChanges(); return(RedirectToAction("Index", new { id = team.Leagueid })); } } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Insert failed"); } } var league = _db.Leagues.Find(team.Leagueid); if (league == null) { return(HttpNotFound()); } var teams = _db.Teams.Where(x => x.Leagueid == team.Leagueid).OrderBy(x => x.TeamNo); var list = RemainingPlayers(team, teams.ToList()); ViewBag.List = list; ViewBag.Teams = teams; ViewBag.TeamSize = league.TeamSize; return(View(team)); }
public ActionResult Create([Bind(Include = "id,username,password,Roles")] User user) { if (ModelState.IsValid) { user.username = user.username.ToLower().Trim(); _db.Users.Add(user); _db.SaveChanges(); return(RedirectToAction("Index")); } var dict = new List <Role>(); dict.Add(new Role("", "No Roles")); dict.Add(new Role("Admin", "Admin")); ViewBag.Roles = new SelectList(dict, "RoleValue", "RoleText", user.Roles); return(View(user)); }
public ActionResult Create([Bind(Include = "id,UserId,LeagueId,Roles,rowversion")] UserLeague userLeague) { if (ModelState.IsValid) { _db.UserLeagues.Add(userLeague); try { _db.SaveChanges(); return(RedirectToAction("Index", new { id = userLeague.LeagueId })); } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Insert failed"); } } var list = _db.Users.Where(x => x.Roles != "Mailer" || x.Roles != "Admin").ToList(); foreach (var item in _db.UserLeagues.Where(x => x.LeagueId == userLeague.LeagueId)) { if (list.Any(x => x.id == item.UserId)) { list.RemoveAll(x => x.id == item.UserId); } } ViewBag.UserId = new SelectList(list, "id", "username"); var league = _db.Leagues.Find(userLeague.LeagueId); ViewBag.LeagueName = league.LeagueName; return(View(userLeague)); }
public ActionResult Create([Bind(Include = "GameDate,LeagueId,Cancelled")] Schedule schedule) { if (ModelState.IsValid) { try { if (ModelState.IsValid) { if (db.Schedules.Any(x => x.GameDate == schedule.GameDate)) { ModelState.AddModelError(string.Empty, "Duplicate date is not allowed"); } else { db.Schedules.Add(schedule); db.SaveChanges(); return(RedirectToAction("Index", new { id = schedule.Leagueid })); } } } catch (System.Data.Entity.Infrastructure.DbUpdateException e) { ErrorSignal.FromCurrentContext().Raise(e); Exception ex = e; while (ex.InnerException != null) { ex = ex.InnerException; } ModelState.AddModelError(string.Empty, ex.Message); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ModelState.AddModelError(string.Empty, "Insert failed"); } } ViewBag.Schedule = db.Schedules.Where(x => x.Leagueid == schedule.Leagueid).OrderBy(x => x.GameDate); return(View(schedule)); }
public ActionResult ChangePassword( [Bind(Include = "EmailAddress,OldPassword, Password,Confirm")] ChangePasswordViewModel chpvm) { if (ModelState.IsValid) { var users = _db.Users.Where(x => x.username == chpvm.EmailAddress.ToLower().Trim()); if (!users.Any()) { ModelState.AddModelError(string.Empty, "User Id or Current Password not found"); return(View(chpvm)); } var user = users.First(); if (user.password != chpvm.OldPassword) { ModelState.AddModelError(string.Empty, "User Id or Current Password not found"); return(View(chpvm)); } if (chpvm.Password != chpvm.Confirm) { ModelState.AddModelError(string.Empty, "New Password and Confirming Password are not the same"); return(View(chpvm)); } try { user.password = chpvm.Password; _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("PasswordAccepted", "Accounts")); } catch { ModelState.AddModelError(string.Empty, "Password was not updated, try again"); } } return(View(chpvm)); }