Exemple #1
0
 public ActionResult Create(EventosModel evento)
 {
     if (ModelState.IsValid)
     {
         HttpResponseMessage response = GlobalSettings.WebApiClient.PostAsJsonAsync("Eventos", evento).Result;
         if (response.IsSuccessStatusCode)
         {
             var          result      = response.Content.ReadAsStringAsync().Result;
             EventosModel eventResult = JsonConvert.DeserializeObject <EventosModel>(result);
             foreach (var item in evento.ParticipanteEvento)
             {
                 if (!String.IsNullOrEmpty(item.Participante) && !item.Participante.Equals(""))
                 {
                     ParticipanteEventoModel pem = new ParticipanteEventoModel();
                     pem.EventoID     = eventResult.EventoID;
                     pem.Participante = item.Participante;
                     HttpResponseMessage responseParticipante = GlobalSettings.WebApiClient.PostAsJsonAsync("ParticipanteEventos", pem).Result;
                 }
             }
         }
         TempData["SuccessMessage"] = "Evento Guardado";
         return(RedirectToAction("Index"));
     }
     return(PartialView("Create", evento));
 }
Exemple #2
0
        public EventosModel EmptyEvento()
        {
            EventosModel ev = new EventosModel {
                ParticipanteEvento = new List <ParticipanteEventoModel>()
            };

            for (int i = 0; i < 5; i++)
            {
                ParticipanteEventoModel pt = new ParticipanteEventoModel {
                    EventoID = 0, Participante = ""
                };
                ev.ParticipanteEvento.Add(pt);
            }
            return(ev);
        }