public void PostResponse(GuestResponse response)
 {
     if (ModelState.IsValid)
     {
         Repository.Add(response);
     }
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
         return View("Thanks", guestResponse);
     else
         return View();
 }
 public ViewResult RsvpForm(GuestResponse response)
 {
     // TODO: Email response to party organizer
     if (ModelState.IsValid)
         return View("Thanks", response);
     else
         return View();
 }
 public ViewResult RsvpForm(GuestResponse guestResponse) {
     if (ModelState.IsValid) {
         //TODO: Send email
         return View("Thanks", guestResponse);
     } else {
         return View();
     }
 }
Exemple #5
0
        public static void Add(GuestResponse newResponse)
        {
            string key = newResponse.Name.ToLowerInvariant();

            if (responses.ContainsKey(key))
                responses[key] = newResponse;
            else
                responses.Add(key, newResponse);
        }
 public ActionResult Rsvp(GuestResponse response)
 {
     if (ModelState.IsValid) {
         Repository.Add(response);
         return View("Thanks", response);
     } else {
         return View();
     }
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid) {
         return View("Thanks", guestResponse);
     } else {
         // there is a validation error - redisplay the form
         return View();
     }
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
         // TODO: Email response to the party organizer
         return View("Thanks", guestResponse);
     else
         //there is a validation error
         return View();
 }
 public void Handles_WillAttend_Null_Values()
 {
     // Arrange
     IRepository repo = new MockRepository();
     IPresenter<GuestResponse> target = new RsvpPresenter { Repository = repo };
     // Act
     GuestResponse dataObject
         = new GuestResponse { Name = "TEST", WillAttend = null };
     IResult result = target.GetResult(dataObject);
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         guestResponse.Submit();
         return View("Thanks", guestResponse);
     }
     else // Validation error, so redisplay data entry form
         return View();
 }
 public ActionResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         return View("Thanks", guestResponse);
     }
     else
     {
         return View();
     }
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         // TODO: Email response to the party organizer
         return View("Thanks", guestResponse);
     } else
     {
         return View();
     }
 }
Exemple #13
0
 public static void Add(GuestResponse newResponse)
 {
     if (responses.ContainsKey(newResponse.Name.ToLowerInvariant()))
     {
         responses[newResponse.Name] = newResponse;
     }
     else
     {
         responses.Add(newResponse.Name, newResponse);
     }
 }
Exemple #14
0
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         return View("Thanks", guestResponse);
     }
     else
     {
         //there is validation Error
         return View();
     }
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         guestResponse.Submit();
         return View("Thanks", guestResponse);
     }
     else
     {
         return View();
     }
 }
Exemple #16
0
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     //Проверка правильности введенных данных
     if (ModelState.IsValid)
     {
         //Чтото сделать: отправить guestResponse по эл. почте организатору 
         //вечеринки
         return View("Thanks", guestResponse);
     }
     // В случае ошибки данных 
     return View();
 }
Exemple #17
0
        public static void Add(GuestResponse response)
        {
            var key = response.Name.ToLowerInvariant();

            if (_responses.ContainsKey(key))
            {
                _responses[key] = response;
            }
            else
            {
                _responses.Add(key, response);
            }
        }
Exemple #18
0
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         //TODO: Email response
         return View("ThankYou", guestResponse);
     }
     else
     {
         //there is validation error
         return View();
     }
 }
Exemple #19
0
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
     //Отправить guestRespons по электронной почте
     //организатору вечеринки
     return View("Thanks", guestResponse);
     }
     else
     {
         return View();
     }
 }
Exemple #20
0
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     if (ModelState.IsValid)
     {
         // TODO: Email guestResponse to the part organizer
         return View("Thanks", guestResponse);
     }
     else
     {
         // there is a validation error - redisplay the form
         return View();
     }
 }
 public ViewResult RsvpForm(GuestResponse gr)
 {
     if (ModelState.IsValid)
     {
         //TODO: email response to the party organizer
         return View("Thanks", gr);
     }
     else
     {
         // validation error
         return View();
     }
 }
 public void Adds_Object_To_Repository()
 {
     // Arrange
     IRepository repo = new MockRepository();
     IPresenter<GuestResponse> target = new RsvpPresenter { Repository = repo };
     GuestResponse dataObject =
         new GuestResponse { Name = "TEST", WillAttend = true };
     // Act
     IResult result = target.GetResult(dataObject);
     // Assert
     Assert.AreEqual(repo.GetAllResponses().Count(), 3);
     Assert.AreEqual(repo.GetAllResponses().Last().Name, "TEST");
     Assert.AreEqual(repo.GetAllResponses().Last().WillAttend, true);
 }
 public void Handles_WillAttend_Values()
 {
     // Arrange
     IRepository repo = new MockRepository();
     IPresenter<GuestResponse> target = new RsvpPresenter { Repository = repo };
     bool?[] values = { true, false };
     // Act & Assert
     foreach (bool? testValue in values)
     {
         GuestResponse dataObject =
             new GuestResponse { Name = "TEST", WillAttend = testValue };
         IResult result = target.GetResult(dataObject);
         Assert.IsInstanceOfType(result, typeof(RedirectResult));
     }
 }
        private void registrarDatos(GuestResponse guest)
        {
            MiDBContextDataContext db = new MiDBContextDataContext(); 
            db.Guests.InsertOnSubmit(new Guest { Name = guest.Name, Phone = guest.Phone, Attend = guest.WillAttend, Email = guest.Email }); // Insert
            db.SubmitChanges();

            Guest g = db.Guests.Where(x => x.Email == guest.Email).Single();  // Update
            g.Name = "Jesus";
            db.SubmitChanges();

            foreach(Guest gu in db.Guests)
            {
                db.Guests.DeleteOnSubmit(gu); // Delete Todo, Truncate Table
            }           
            db.SubmitChanges();
        }
 [HttpPost] // Si el cliente en vez de pedir la pagina RsvpForm con el metodo Get, lo pide por Post ( metodo por defecto de los HTML.BeginForm() ) entrara por aqui en vez de por arriba
 public ViewResult RsvpForm(GuestResponse guest) // Indicamos que cuando llamemos a esta View usando este controlador, pasaremos un Modelo GuestResponse ( que si recordamos era el que bindeabamos para rellenar en la View )
 {
     // Aqui deberia ir el metodo de mandar Email que tenemos escrito en la pagina Thanks.cshtml
     if (ModelState.IsValid) // Esta sentencia recoge el estado de todos los atributos con campo Required del modelo GuestResponse que, al bindear usando la View, ya saben si validan o no, y este metodo los comprueba siendo True en caso de que todas las validaciones sean correctas.
     {
         enviarEmail(guest);
         registrarDatos(guest);                
         return View("Thanks", guest); // Cargamos la pagina Thanks ( si queremos cargar una pagina en concreto, le pasamos un String con el nombre sin extension al View ) y le damos el modelo que lo recibe como Object la View 
                                       // ( si nos fijamos en thanks indicamos con @model que el modelo que le pasamos es GuestResponse, para entendernos, es como si al entrar en la View, 
                                       // la propia View le hiciera un Cast para poder trabajar con el modelo GuestResponse mediante la clase Model sin tener que hacerselo nosotros )
     }
     else
     {
         return View();
     }
 }
        public ViewResult RsvpForm(GuestResponse guestResponse)
        {
            if (ModelState.IsValid == true)
            {
                //add code to mail the organizer
                //
                //
                //
                //
                return View("Thanks", guestResponse);
            }
            else
            {
                //there was a validation error - redisplay the form
                return View();

            }
        }
 private void enviarEmail(GuestResponse guest)
 {             
     try
     {
         WebMail.SmtpServer = "smtp.example.com";
         WebMail.SmtpPort = 587;
         WebMail.EnableSsl = true;
         WebMail.UserName = "******";
         WebMail.Password = "******";
         WebMail.From = "*****@*****.**";
         WebMail.Send("*****@*****.**", "RSVP Notification", guest.Name + " is " + ((guest.WillAttend ?? false) ? "" : "not") + " attending");
         ViewBag.Email = "An Email was sent succesfully to our organizator.";
     }
     catch (Exception)
     {
     ViewBag.Email = "Sorry - we couldn't send the email to confirm your RSVP";
     }            
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     return View("Thanks", guestResponse);
 }
Exemple #29
0
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     // TODO: Email response to the party organizer
     return View("Thanks", guestResponse);
 }
 public ViewResult RsvpForm(GuestResponse guestResponse)
 {
     return ModelState.IsValid ? View("Thanks", guestResponse) : View();
 }