コード例 #1
0
        // GET: Screen
        public ActionResult Index(string msj, Guid tk)
        {
            Invitado inv = db.Invitado.Where(i => i.id_invitado == tk).SingleOrDefault();

            string mensaje = string.Empty;
            string fecha   = inv.Evento.fecha_evento.ToShortDateString();
            string hd      = inv.Evento.hora_desde.ToShortTimeString();
            string hh      = inv.Evento.hora_hasta.ToShortTimeString();

            string hora = string.Empty;

            //evento aun no es la fecha de inicio
            if (msj == "evant")
            {
                hora = hd + " a " + hh;
            }

            //evento ya paso la fecha o la hora
            if (msj == "evde")
            {
                hora = hh;
            }

            //evento es hoy pero aun no inicia
            if (msj == "evant_h")
            {
                hora = hd;
            }

            mensaje = string.Format(rm.GetString(msj), fecha, hora);

            ViewBag.mensaje = mensaje;
            return(View());
        }
コード例 #2
0
 public string DeleteInvitadoDomainService(Invitado invitado)
 {
     if (invitado == null)
     {
         return("No se Encuentra el Invitado");
     }
     return(null);
 }
コード例 #3
0
 public string PutInvitadoDomainService(int id, Invitado invitado)
 {
     if (invitado == null)
     {
         return("No se Encuentra el Invitado");
     }
     return(null);
 }
コード例 #4
0
ファイル: EventoAppService.cs プロジェクト: Danro1994/EMApp
        private async Task <Reservacion> LlamadaALaBaseDeDatos(Evento evento)
        {
            CategoriaEvento categoriaEvento = await _baseDatos.categoriaEventos.FirstOrDefaultAsync(q => q.id == evento.categoriaEventoid);

            Invitado invitado = await _baseDatos.invitados.FirstOrDefaultAsync(q => q.id == evento.invitadoid);

            var reservarcion = new Reservacion(categoriaEvento, evento, invitado);

            return(reservarcion);
        }
コード例 #5
0
        public ActionResult AddInvitado(EventoModels evento_)
        {
            if (!string.IsNullOrEmpty(evento_.invitados))
            {
                //validamos los emails
                bool emailerror = false;
                foreach (var i in evento_.invitados.Split(','))
                {
                    if (!IsValidEmail(i.Trim()))
                    {
                        emailerror = true;
                        break;
                    }
                }
                if (emailerror != true)
                {
                    List <Invitado> liv = new List <Invitado>();
                    Evento          ev  = db.Evento.Where(r => r.id_evento == evento_.id_evento).SingleOrDefault();
                    foreach (var i in evento_.invitados.Split(','))
                    {
                        Invitado iv = new Invitado();
                        iv.id_invitado       = Guid.NewGuid();
                        iv.email             = i;
                        iv.id_evento         = evento_.id_evento;
                        iv.asistio           = false;
                        iv.codigo_asistencia = Guid.NewGuid();
                        iv.ip = string.Empty;

                        liv.Add(iv);
                    }
                    if (liv.Count() != 0)
                    {
                        db.Invitado.AddRange(liv);

                        db.SaveChanges();
                    }

                    foreach (var e in liv)
                    {
                        //DESPUES DE CREAR EL EVENTO SE ENVIAN LAS INVITACIONES
                        SendInvitation(e.email, ev.nombre, ev.fecha_evento, ev.descripcion, ev.id_evento.ToString(), ev.hora_desde.ToShortTimeString(), ev.hora_hasta.ToShortTimeString(), e);
                    }
                }
                else
                {
                    //si algun email esta mal formateado
                    evento_.ShowError    = true;
                    evento_.Clean        = false;
                    evento_.type         = TypeError.warning;
                    evento_.title        = Titles.Atención;
                    evento_.ErrorMessage = rm.GetString("mail_error");
                }
            }
            return(RedirectToAction("Edit", new { id = evento_.id_evento }));
        }
コード例 #6
0
ファイル: InvitadoController.cs プロジェクト: Danro1994/EMApp
        public async Task <IActionResult> PutInvitado(int id, Invitado invitado)
        {
            var respuestaAutoloteAppService = await _invitadoAppService.PutInvitadoApplicationService(id, invitado);

            bool noHayErroresEnLasValidaciones = respuestaAutoloteAppService == null;

            if (noHayErroresEnLasValidaciones)
            {
                return(NoContent());
            }
            return(null);
        }
コード例 #7
0
        public ActionResult DeleteInvitado(Guid id)
        {
            Invitado iv = db.Invitado.Where(i => i.id_invitado == id).SingleOrDefault();

            if (iv != null)
            {
                db.Invitado.Remove(iv);
                db.SaveChanges();
            }

            return(RedirectToAction("Edit", new { id = iv.id_evento }));
        }
コード例 #8
0
ファイル: InvitadoController.cs プロジェクト: Danro1994/EMApp
        public async Task <ActionResult <Invitado> > PostInvitado(Invitado invitado)
        {
            var respuestaAutoloteAppService = await _invitadoAppService.PostInvitadoApplicationService(invitado);

            bool noHayErroresEnLasValidaciones = respuestaAutoloteAppService == null;

            if (noHayErroresEnLasValidaciones)
            {
                return(CreatedAtAction(nameof(GetInvitado), new { id = invitado.id }, invitado));
            }
            return(null);
        }
コード例 #9
0
        public IHttpActionResult PutInvitados(Invitado invitado)
        {
            Invitado invitadoR = invitados.UpdateInvitado(invitado);

            if (!String.IsNullOrEmpty(invitadoR.mensajeError))
            {
                return(Content(HttpStatusCode.NotFound, invitadoR.mensajeError));
            }
            else
            {
                return(Content(HttpStatusCode.OK, invitadoR));
            }
        }
コード例 #10
0
        public IHttpActionResult DeleteInvitados([FromBody] string cedula)
        {
            Invitado invitadoR = invitados.DeleteInvitado(cedula);

            if (!String.IsNullOrEmpty(invitadoR.mensajeError))
            {
                return(Content(HttpStatusCode.NotFound, invitadoR.mensajeError));
            }
            else
            {
                return(Content(HttpStatusCode.OK, invitadoR));
            }
        }
コード例 #11
0
 public ActionResult Post([FromBody] Invitado invitado)
 {
     try
     {
         context.invitados.Add(invitado);
         context.SaveChanges();
         return(CreatedAtRoute("GetInvitado", new { id = invitado.IdInvitado }, invitado));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #12
0
        public void PruebaParaValidarQueSeEncuentraUnInvitado3()
        {
            // Arrange
            var invitado = new Invitado();
            var id       = new int();

            invitado = null;
            // Act
            var invitadoDomainService = new InvitadoDomainService();
            var resultado             = invitadoDomainService.DeleteInvitadoDomainService(invitado);

            // Assert
            Assert.AreEqual("No se Encuentra el Invitado", resultado);
        }
コード例 #13
0
ファイル: InvitadoAppService.cs プロジェクト: Danro1994/EMApp
        public async Task <String> PutInvitadoApplicationService(int id, Invitado invitado)
        {
            var respuestaDomainService = _invitadoDomainService.PutInvitadoDomainService(id, invitado);

            bool hayErrorEnElDomainService = respuestaDomainService != null;

            if (hayErrorEnElDomainService)
            {
                return(respuestaDomainService);
            }
            _baseDatos.Entry(invitado).State = EntityState.Modified;
            await _baseDatos.SaveChangesAsync();

            return(null);
        }
コード例 #14
0
        private void btnIngresoInvitado_Click(object sender, EventArgs e)
        {
            int dniUsuario;

            if (int.TryParse(this.txtBoxDNI.Text, out dniUsuario))
            {
                Invitado nuevoInvitado = Negocio.AgregarInvitado(this.txtBoxUsername.Text, dniUsuario);
                this.Hide();
                new ControlPanelForm(nuevoInvitado).Show();
            }
            else
            {
                MessageBox.Show("Ya hay ingresado un Cliente con ese DNI", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #15
0
        public void PruebaParaValidarQueSeEncuentraUnInvitado()
        {
            // Arrange
            var invitado        = new Invitado();
            var categoriaEvento = new CategoriaEvento();
            var evento          = new Evento();

            invitado = null;
            var reservacion = new Reservacion(categoriaEvento, evento, invitado);
            // Act
            var eventoDomainService = new EventoDomainService();
            var resultado           = eventoDomainService.PosttEventoDomainService(reservacion);

            // Assert
            Assert.AreEqual("El Invitado no existe", resultado);
        }
コード例 #16
0
ファイル: InvitadoAppService.cs プロジェクト: Danro1994/EMApp
        public async Task <String> PostInvitadoApplicationService(Invitado invitado)
        {
            var respuestaDomainService = _invitadoDomainService.PostInvitadoDomainService(invitado);

            bool hayErrorEnElDomainService = respuestaDomainService != null;

            if (hayErrorEnElDomainService)
            {
                return(respuestaDomainService);
            }

            _baseDatos.invitados.Add(invitado);
            await _baseDatos.SaveChangesAsync();

            return(null);
        }
コード例 #17
0
        public void PruebaParaValidarQueSeEncuentraUnEvento3()
        {
            // Arrange
            var invitado        = new Invitado();
            var categoriaEvento = new CategoriaEvento();
            var evento          = new Evento();
            var id = new int();

            evento = null;
            var reservacion = new Reservacion(categoriaEvento, evento, invitado);
            // Act
            var eventoDomainService = new EventoDomainService();
            var resultado           = eventoDomainService.DeletetEventoDomainService(id, evento);

            // Assert
            Assert.AreEqual("No se encuentro el Evento", resultado);
        }
コード例 #18
0
 public async Task <IActionResult> Post(Invitado entidad)
 {
     try
     {
         if (ModelState.IsValid)
         {
             contexto.Invitado.Add(entidad);
             contexto.SaveChanges();
             return(CreatedAtAction(nameof(Get), new { id = entidad.IdInvitado }, entidad));
         }
         return(BadRequest());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
コード例 #19
0
        public bool Invitar(Guid id)
        {
            try
            {
                Invitado inv = db.Invitado.Where(r => r.id_invitado == id).SingleOrDefault();

                if (inv != null)
                {
                    SendInvitation(inv.email, inv.Evento.nombre, inv.Evento.fecha_evento, inv.Evento.descripcion, inv.Evento.id_evento.ToString(), inv.Evento.hora_desde.ToShortTimeString(), inv.Evento.hora_hasta.ToShortTimeString(), inv);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #20
0
 public async Task <IActionResult> Put(int id, Invitado entidad)
 {
     try
     {
         if (ModelState.IsValid)
         {
             entidad.IdInvitado = id;
             contexto.Invitado.Update(entidad);
             contexto.SaveChanges();
             return(Ok(entidad));
         }
         return(BadRequest());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
コード例 #21
0
 public ActionResult Put(int id, [FromBody] Invitado invitado)
 {
     try
     {
         if (invitado.IdInvitado == id)
         {
             context.Entry(invitado).State = EntityState.Modified;
             context.SaveChanges();
             return(CreatedAtRoute("GetInvitado", new { id = invitado.IdInvitado }, invitado));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #22
0
 public string PostInvitadoDomainService(Invitado invitado)
 {
     return(null);
 }
コード例 #23
0
 private void SendInvitation(string toAddress, string evento, DateTime fecha, string descipcion, string idevento, string hd, string hh, Invitado inv)
 {
     SendMail(toAddress, SetEmailBody(evento, fecha, descipcion, idevento, hd, hh, inv), ConfigurationManager.AppSettings["EmailSubjec"]);
 }
コード例 #24
0
        // GET: Estudio

        public ActionResult Room()
        {
            var re      = Request;
            var headers = re.Headers;

            Guid code = Guid.Parse(Request["tk"]);

            ViewBag.otro = "otra vaina";

            Invitado inv = db.Invitado.Where(i => i.id_invitado == code).SingleOrDefault();
            DateTime hd  = DateTime.Today.AddHours(inv.Evento.hora_desde.Hour).AddMinutes(inv.Evento.hora_desde.Minute);
            DateTime hh  = DateTime.Today.AddHours(inv.Evento.hora_hasta.Hour).AddMinutes(inv.Evento.hora_hasta.Minute);

            if (inv != null)
            {
                //se valida si el evento es hoy
                if (inv.Evento.fecha_evento.Date == DateTime.Today.Date)
                {
                    //validamos que el evento esta dentro del rango de horas
                    if (hd <= DateTime.Now && hh > DateTime.Now)
                    {
                        ViewBag.room        = inv.Evento.id_evento;
                        ViewBag.displayname = inv.email;
                        //ViewBag.disable = "disable";
                        //ViewBag.enabled = "enabled";

                        ViewBag.disable = "enabled";
                        ViewBag.enabled = "disable";
                    }
                    else
                    {
                        //la hora de inicio del evento aun no inicia
                        if (hd > DateTime.Now)
                        {
                            return(RedirectToAction("Index", "Screen", new { msj = "evant_h", tk = code }));
                        }

                        //validamos que el evento era hoy pero ya la hora "hasta" se paso
                        if (hh < DateTime.Now)
                        {
                            return(RedirectToAction("Index", "Screen", new { msj = "evde", tk = code }));
                        }
                    }
                }
                else
                {
                    string tipo_msj = string.Empty;

                    //se valida si el evento aun no inicia
                    if (inv.Evento.fecha_evento.Date > DateTime.Today.Date)
                    {
                        tipo_msj = "evant";
                    }


                    //se valida si la fecha del evento ya paso
                    if (inv.Evento.fecha_evento.Date < DateTime.Today.Date)
                    {
                        tipo_msj = "evde";
                    }

                    return(RedirectToAction("Index", "Screen", new { msj = tipo_msj, tk = code }));
                }
            }

            return(View());
        }
コード例 #25
0
        private AlternateView SetEmailBody(string evento, DateTime fecha, string descripcion, string idevento, string hd, string hh, Invitado inv)
        {
            try
            {
                //se arma el correo que se envia para el ambio de clave
                string plantilla = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["InvitationTemplate"]);
                string url       = ConfigurationManager.AppSettings["urlevento"];

                url = url + "?tk=" + inv.id_invitado;
                var html = System.IO.File.ReadAllText(plantilla);
                html = html.Replace("{{event}}", evento);
                html = html.Replace("{{mes}}", fecha.Day.ToString() + " de " + fecha.ToString("MMMM", CultureInfo.CreateSpecificCulture("es")).ToUpper());
                html = html.Replace("{{dia}}", hd + " - " + hh);
                html = html.Replace("{{descripcion}}", descripcion);
                html = html.Replace("{{action_url}}", url);

                AlternateView av = AlternateView.CreateAlternateViewFromString(html, null, "text/html");

                //create the LinkedResource(embedded image)
                //LinkedResource logo = new LinkedResource(HttpContext.Server.MapPath("..\\Content\\MailTemplates\\images\\9701519718227204.jpg"));
                //logo.ContentId = "fondo";

                //av.LinkedResources.Add(logo);

                return(av);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #26
0
        public ActionResult Create([Bind(Include = "id_evento,id_categoria,nombre,descripcion,fecha_evento,hora_desde,hora_hasta,duracion,precio,invitados,estado,fecha_creado")] EventoModels evento_)
        {
            try
            {
                DateTime hd       = evento_.hora_desde;
                DateTime hh       = evento_.hora_hasta;
                decimal  duracion = decimal.Parse((hh - hd).TotalHours.ToString());

                evento_.hora_desde_string = evento_.hora_desde.ToShortTimeString();
                evento_.hora_hasta_string = evento_.hora_hasta.ToShortTimeString();

                if (ModelState.IsValid)
                {
                    //validamos los emails
                    bool emailerror = false;
                    foreach (var i in evento_.invitados.Split(','))
                    {
                        if (!IsValidEmail(i.Trim()))
                        {
                            emailerror = true;
                            break;
                        }
                    }


                    if (hh > hd)
                    {
                        evento_.fecha_evento = evento_.fecha_evento.AddHours(1);

                        List <Evento> lev = db.Evento.Where(e => e.fecha_evento == evento_.fecha_evento && e.estado == true &&
                                                            ((e.hora_desde.Hour <hd.Hour && e.hora_hasta.Hour> hd.Hour) ||
                                                             (e.hora_desde.Hour <hh.Hour && e.hora_hasta.Hour> hh.Hour) ||
                                                             (e.hora_desde.Hour >= hd.Hour && e.hora_hasta.Hour <= hh.Hour))
                                                            ).ToList();
                        if (lev.Count() == 0)
                        {
                            if (emailerror != true)
                            {
                                if ((duracion % 1) == 0)
                                {
                                    //si llega hasta aqui es que no hay validaciones fallidas
                                    Evento ev = new Evento();
                                    ev.id_evento    = Guid.NewGuid();
                                    ev.id_categoria = evento_.id_categoria;
                                    ev.nombre       = evento_.nombre;
                                    ev.descripcion  = evento_.descripcion;
                                    ev.fecha_evento = evento_.fecha_evento;
                                    ev.hora_desde   = hd;
                                    ev.hora_hasta   = hh;
                                    ev.precio       = double.Parse(evento_.precio);
                                    ev.duracion     = int.Parse(duracion.ToString());
                                    ev.invitados    = evento_.invitados;
                                    ev.estado       = evento_.estado;

                                    ev.fecha_creado = DateTime.Now;
                                    db.Evento.Add(ev);

                                    List <Invitado> liv = new List <Invitado>();
                                    foreach (var i in evento_.invitados.Split(','))
                                    {
                                        Invitado iv = new Invitado();
                                        iv.id_invitado       = Guid.NewGuid();
                                        iv.email             = i;
                                        iv.id_evento         = ev.id_evento;
                                        iv.asistio           = false;
                                        iv.codigo_asistencia = Guid.NewGuid();
                                        iv.ip = string.Empty;

                                        liv.Add(iv);
                                    }
                                    if (liv.Count() != 0)
                                    {
                                        db.Invitado.AddRange(liv);
                                    }

                                    db.SaveChanges();

                                    foreach (var e in liv)
                                    {
                                        //DESPUES DE CREAR EL EVENTO SE ENVIAN LAS INVITACIONES
                                        SendInvitation(e.email, ev.nombre, ev.fecha_evento, ev.descripcion, ev.id_evento.ToString(), ev.hora_desde.ToShortTimeString(), ev.hora_hasta.ToShortTimeString(), e);
                                    }

                                    evento_.hora_desde_string = "8:00 a. m.";
                                    evento_.hora_hasta_string = "8:00 a. m.";

                                    ev.fecha_evento      = DateTime.Today;
                                    evento_.ShowError    = true;
                                    evento_.Clean        = true;
                                    evento_.type         = TypeError.success;
                                    evento_.title        = Titles.Exito;
                                    evento_.ErrorMessage = rm.GetString("save");
                                }
                                else
                                {
                                    //si algun email esta mal formateado
                                    evento_.ShowError    = true;
                                    evento_.Clean        = false;
                                    evento_.type         = TypeError.warning;
                                    evento_.title        = Titles.Atención;
                                    evento_.ErrorMessage = rm.GetString("horas_Completas");
                                }
                            }
                            else
                            {
                                //si algun email esta mal formateado
                                evento_.ShowError    = true;
                                evento_.Clean        = false;
                                evento_.type         = TypeError.warning;
                                evento_.title        = Titles.Atención;
                                evento_.ErrorMessage = rm.GetString("mail_error");
                            }
                        }
                        else
                        {
                            //si no coincide ninguna fecha con horas
                            evento_.ShowError    = true;
                            evento_.Clean        = false;
                            evento_.type         = TypeError.error;
                            evento_.title        = Titles.Error;
                            evento_.ErrorMessage = rm.GetString("horario_error");
                        }
                    }
                    else
                    {
                        //si las horas son iguales o la hora desde es mayor que la hora hasta
                        evento_.ShowError    = true;
                        evento_.Clean        = false;
                        evento_.type         = TypeError.error;
                        evento_.title        = Titles.Error;
                        evento_.ErrorMessage = rm.GetString("hora_error");
                    }
                }
            }
            catch (Exception ex)
            {
                evento_.ShowError    = true;
                evento_.type         = TypeError.error;
                evento_.ErrorMessage = ex.Message;
            }
            ViewBag.id_categoria = new SelectList(db.CategoriaCurso, "id_categoria", "nombre", evento_.id_categoria);

            return(View(evento_));
        }