public ActionResult Create(FormCollection collection)
 {
     var mmt = new MechManiaTeam();
     // This will try to update all the fields in the model based on the form collection
     if (TryUpdateModel(mmt, "MechManiaTeam", collection))
     {
         if (mmt.account_name == null)
         {
             mmt.account_name = "";
         }
         if (mmt.account_password == null)
         {
             mmt.account_password = "";
         }
         _repository.AddMechManiaTeam(mmt);
         _repository.Save();
         TempData["Message"] = "Team Created";
         return RedirectToAction("Index");
     }
     return View("Create", MakeAdminEditDataFromTeam(mmt));
 }
예제 #2
0
 public void DeleteMechManiaTeam(MechManiaTeam mmt)
 {
     _mechManiaTeams.Remove(mmt);
 }
        private MechManiaTeamAdminEditData MakeAdminEditDataFromTeam(
			MechManiaTeam mechManiaTeam)
        {
            return new MechManiaTeamAdminEditData
                    {
                        MechManiaTeam = mechManiaTeam,
                        Attendees =
                            new SelectList(_repository.GetAllAttendees(),
                                           "person_id",
                                           "People.name")
                    };
        }
 public ActionResult Index(MechmaniaTeamEditData mmted)
 {
     if (!MechmaniaRegistrationIsOpen())
     {
         return View("RegistrationClosed");
     }
     Attendee att1 =
         _repository.GetAllAttendees().SingleOrDefault(
             x => x.People.email == mmted.member_email_1);
     if (att1 == null)
     {
         ModelState.AddModelError("member_email_1",
                                  "Email not found; did you register?");
     }
     Attendee att2 =
         _repository.GetAllAttendees().SingleOrDefault(
             x => x.People.email == mmted.member_email_2);
     if (att2 == null)
     {
         ModelState.AddModelError("member_email_2",
                                  "Email not found; did you register?");
     }
     Attendee att3 =
         _repository.GetAllAttendees().SingleOrDefault(
             x => x.People.email == mmted.member_email_3);
     if (att3 == null)
     {
         ModelState.AddModelError("member_email_3",
                                  "Email not found; did you register?");
     }
     if (ModelState.IsValid)
     {
         var mmt = new MechManiaTeam
                     {
                         team_name = mmted.team_name,
                         member1_id = att1.person_id,
                         member2_id = att2.person_id,
                         member3_id = att3.person_id,
                         account_name = "",
                         account_password = ""
                     };
         _repository.AddMechManiaTeam(mmt);
         _repository.Save();
         SettingsData settings = SettingsData.Default;
         var message1 = new MailMessage(settings.EmailFrom,
                                        att1.People.email,
                                        settings.RegistrationSubject,
                                        settings.RegistrationMessage.Replace(
                                         "{name}", att1.People.name).Replace(
                                             "{role}", "Mechmania Participant"));
         var message2 = new MailMessage(settings.EmailFrom,
                                        att2.People.email,
                                        settings.RegistrationSubject,
                                        settings.RegistrationMessage.Replace(
                                         "{name}", att2.People.name).Replace(
                                             "{role}", "Mechmania Participant"));
         var message3 = new MailMessage(settings.EmailFrom,
                                        att3.People.email,
                                        settings.RegistrationSubject,
                                        settings.RegistrationMessage.Replace(
                                         "{name}", att3.People.name).Replace(
                                             "{role}", "Mechmania Participant"));
         try
         {
             Mailer.Send(message1);
             Mailer.Send(message2);
             Mailer.Send(message3);
         }
         catch
         {
             //TODO: log this
         }
         return RedirectToAction("Success");
     }
     return View("Index", mmted);
 }
예제 #5
0
 public void AddMechManiaTeam(MechManiaTeam mmt)
 {
     mmt.id = ++_mechManiaTeamMaxId;
     _mechManiaTeams.Add(mmt);
 }
 public void DeleteMechManiaTeam(MechManiaTeam mmt)
 {
     _conferenceware.MechManiaTeams.DeleteOnSubmit(mmt);
 }
 public void AddMechManiaTeam(MechManiaTeam mmt)
 {
     _conferenceware.MechManiaTeams.InsertOnSubmit(mmt);
 }
 partial void DeleteMechManiaTeam(MechManiaTeam instance);
 partial void UpdateMechManiaTeam(MechManiaTeam instance);
 partial void InsertMechManiaTeam(MechManiaTeam instance);
		private void detach_MechManiaTeams2(MechManiaTeam entity)
		{
			this.SendPropertyChanging();
			entity.Attendee2 = null;
		}
		private void attach_MechManiaTeams1(MechManiaTeam entity)
		{
			this.SendPropertyChanging();
			entity.Attendee1 = this;
		}