Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,ClientId,Genero,Nombre,Raza,TipodeSangre")] Paciente paciente, HttpPostedFileBase ImagenMascota)
        {
            if (ImagenMascota != null && ImagenMascota.ContentLength > 0)
            {
                HttpPostedFileBase fileBase = Request.Files[0];
                WebImage           image    = new WebImage(fileBase.InputStream);

                paciente.ImagenMascota = image.GetBytes();



                //byte[] imagendata = null;
                //using (var binarypaciente = new BinaryReader(ImagenMascota.InputStream))
                //{
                //    imagendata = binarypaciente.ReadBytes(ImagenMascota.ContentLength);

                //}
                //paciente.ImagenMascota = imagendata;
            }
            if (ModelState.IsValid)
            {
                db.Pacientes.Add(paciente);
                db.SaveChanges();
                log.Info("Creacion de paciente");
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientId = new SelectList(db.Clientes, "Id", "NombreCompleto", paciente.ClientId);
            return(View(paciente));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Localizacion")] Sala sala)
        {
            if (ModelState.IsValid)
            {
                db.Salas.Add(sala);
                db.SaveChanges();
                log.Info(string.Format("Creacion de una sala / {0} / {1} / {2}", sala.Id, sala.Localizacion, sala.Nombre));
                return(RedirectToAction("Index"));
            }

            return(View(sala));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Precio")] Producto producto)
        {
            if (ModelState.IsValid)
            {
                db.Productos.Add(producto);
                db.SaveChanges();
                log.Info("Creacion de producto");
                return(RedirectToAction("Index"));
            }

            return(View(producto));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,NombreCompleto,Email,Direccion,Dni,Telefono")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                db.Clientes.Add(cliente);
                db.SaveChanges();
                log.Info("Creacion de cliente");
                return(RedirectToAction("Index"));
            }

            return(View(cliente));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Email,TipoEspecialidad,Telefono,Direccion")] Doctor doctor)
        {
            if (ModelState.IsValid)
            {
                db.Doctores.Add(doctor);
                db.SaveChanges();
                log.Info("Creacion de doctor");
                return(RedirectToAction("Index"));
            }

            return(View(doctor));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Id,IdPaciente,Descripcion,Fecha")] HistorialPaciente historialPaciente)
        {
            if (ModelState.IsValid)
            {
                historialPaciente.Fecha = DateTime.Now;
                db.HistorialPacientes.Add(historialPaciente);
                db.SaveChanges();
                log.Info("Creacion de historial de paciente");
                return(RedirectToAction("Index"));
            }

            ViewBag.IdPaciente = new SelectList(db.Pacientes, "Id", "Nombre", historialPaciente.IdPaciente);
            return(View(historialPaciente));
        }
Ejemplo n.º 7
0
        public void Update(Patient entity)
        {
            var db = new VetDbContext();

            db.Entry(entity).State = EntityState.Modified;
            db.SaveChanges();
        }
Ejemplo n.º 8
0
        public Patient Insert(Patient entity)
        {
            var db = new VetDbContext();

            db.Patients.Add(entity);
            db.SaveChanges();
            return(entity);
        }
Ejemplo n.º 9
0
        public void Delete(int id)
        {
            var db      = new VetDbContext();
            var patient = db.Patients.Include(a => a.Owner).Where(x => x.Id == id).Single();

            db.Patients.Remove(patient);
            db.SaveChanges();
        }
Ejemplo n.º 10
0
        public Appointment Insert(Appointment entity)
        {
            var db = new VetDbContext();

            db.Appointments.Add(entity);
            db.SaveChanges();
            return(entity);
        }
Ejemplo n.º 11
0
        public void Delete(int id)
        {
            var db     = new VetDbContext();
            var client = db.Clients.Find(id);

            db.Clients.Remove(client);
            db.SaveChanges();
        }
Ejemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Id,IdDoctor,IdSala,TipoEspecialidad,HorarioTurno,Dia")] Atencion atencion)
        {
            if (ModelState.IsValid)
            {
                RepositoryDoctor repositoryDoctor = new RepositoryDoctor();

                foreach (var item in repositoryDoctor.List())
                {
                    if (item.Id == atencion.IdDoctor)
                    {
                        atencion.TipoEspecialidad = item.TipoEspecialidad;
                    }
                }


                int valor = 0;
                RepositoryAtencion repository = new RepositoryAtencion();

                valor = atencion.verificardisponibilidadsala(repository, atencion);
                //foreach (var x in repository.List())
                //{
                //    if (x.Dia == atencion.Dia && x.HorarioTurno == atencion.HorarioTurno && x.IdSala == atencion.IdSala)
                //    {
                //        valor = 1;
                //    }
                //}

                if (valor == 1)
                {
                    string aviso = "Ya se encuentra un Empleado en ese dia, ese turno y esa sala.";
                    ViewBag.advertencia = aviso;
                }
                else
                {
                    db.Atenciones.Add(atencion);
                    db.SaveChanges();
                    log.Info("Creacion de atencion");
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.IdDoctor = new SelectList(db.Doctores, "Id", "Nombre", atencion.IdDoctor);
            ViewBag.IdSala   = new SelectList(db.Salas, "Id", "Nombre", atencion.IdSala);
            return(View(atencion));
        }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "Id,IdCliente,IdProducto,Cantidad,Fecha,Monto")] FacturaProducto facturaProducto)
        {
            if (ModelState.IsValid)
            {
                facturaProducto.Fecha = DateTime.Now;
                RepositoryProducto repositoryProducto = new RepositoryProducto();
                Producto           prod = new Producto();
                prod = repositoryProducto.GetById(facturaProducto.IdProducto);
                facturaProducto.Monto = prod.Precio * facturaProducto.Cantidad;
                db.FacturaProductos.Add(facturaProducto);
                db.SaveChanges();
                log.Info("Creacion de factura producto");
                return(RedirectToAction("Index"));
            }

            ViewBag.IdCliente  = new SelectList(db.Clientes, "Id", "NombreCompleto", facturaProducto.IdCliente);
            ViewBag.IdProducto = new SelectList(db.Productos, "Id", "Nombre", facturaProducto.IdProducto);
            return(View(facturaProducto));
        }
        public ActionResult Create([Bind(Include = "Id,IdTurno,Fecha,Monto")] FacturaServicio facturaServicio)
        {
            if (ModelState.IsValid)
            {
                facturaServicio.Fecha = DateTime.Now;
                RepositoryTurno repositoryturno = new RepositoryTurno();
                Turno           modelturno      = new Turno();
                modelturno         = repositoryturno.GetById(facturaServicio.IdTurno);
                modelturno.Abonado = true;
                repositoryturno.Update(modelturno);

                db.FacturaServicios.Add(facturaServicio);
                db.SaveChanges();
                log.Info("Creacion de Factura servicio");
                return(RedirectToAction("Index"));
            }

            ViewBag.IdTurno = new SelectList(db.Turnos, "Id", "Id", facturaServicio.IdTurno);
            return(View(facturaServicio));
        }
Ejemplo n.º 15
0
        public void Delete(int id)
        {
            var db          = new VetDbContext();
            var appointment = db.Appointments.Include(a => a.Doctor).
                              Include(a => a.Patient).
                              Include(a => a.Patient.Owner).
                              Include(a => a.Room).
                              Where(x => x.Id == id).Single();

            db.Appointments.Remove(appointment);
            db.SaveChanges();
        }
Ejemplo n.º 16
0
 public virtual void Save()
 {
     try
     {
         context.SaveChanges();
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                               eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                   ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
 }
Ejemplo n.º 17
0
        public ActionResult Create([Bind(Include = "Id,TipoEspecialidad,Fecha,IdPaciente,IdAtencion,Hora,Abonado")] Turno turno)
        {
            RepositoryAtencion repositoryatencion = new RepositoryAtencion();
            RepositoryTurno    repositoryTurno    = new RepositoryTurno();
            RepositoryDoctor   repositoryDoctor   = new RepositoryDoctor();

            int    valoratencion = 1;
            string diaturno;

            diaturno = turno.Fecha.DayOfWeek.ToString();
            List <Atencion> lstatencionvalidas = new List <Atencion>();

            if (turno.IdAtencion == 0)
            {
                foreach (var item in repositoryatencion.List())
                {
                    turno.IdAtencion = item.Id;
                    valoratencion    = turno.verificarcoordinacionconatencion(repositoryatencion, turno);

                    if (valoratencion == 0)
                    {
                        if (turno.TipoEspecialidad == item.TipoEspecialidad)
                        {
                            if (turno.Atencion.Dia.ToString() == diaturno)
                            {
                                foreach (var item3 in repositoryDoctor.List())
                                {
                                    if (item.IdDoctor == item3.Id)
                                    {
                                        item.Doctor = item3;
                                    }
                                }

                                lstatencionvalidas.Add(item);
                            }

                            valoratencion = 1;
                        }
                    }
                }

                turno.IdAtencion = 0;
                //IEnumerable<Atencion> lst;
                //lst = lstatencionvalidas;
                if (lstatencionvalidas.Count > 0)
                {
                    //ViewBag.Atenciones = lstatencionvalidas.Select(m => new SelectListItem { Text = m.Id.ToString(), Value = m.Id.ToString() });
                    ViewBag.IdAtencion = new SelectList(lstatencionvalidas, "Id", "Doctor.Nombre");
                }

                ViewBag.IdPaciente = new SelectList(db.Pacientes, "Id", "Nombre", turno.IdPaciente);
                return(View(turno));
            }

            //List<Atencion> lstatencion = new List<Atencion>();

            //foreach (var item in repositoryatencion.List())
            //{
            //    if (item.TipoEspecialidad == turno.TipoEspecialidad)
            //    {
            //        lstatencion.Add(item);
            //    }
            //}
            //ViewBag.IdAtencion = new SelectList(lstatencion, "Id", "Id", turno.IdAtencion);
            if (ModelState.IsValid)
            {
                int valor2 = 0;

                valor2 = turno.validarhora(turno);



                Atencion natencion = new Atencion();
                natencion = repositoryatencion.GetById(turno.IdAtencion);
                int valor = 0;


                valor = turno.verificarrepeticion(repositoryTurno, turno);



                int valor3 = 1;

                //valor3 = turno.verificarcoordinacionconatencion(repositoryatencion, turno);


                valor3 = 0;

                if (valor3 == 1)
                {
                    ViewBag.advertencia4 = string.Format("El doctor no se encuentra en este horario, esta en el horario de {0} .", natencion.HorarioTurno);
                }

                if (valor == 1)
                {
                    ViewBag.advertencia = "Ya hay alguien asignado en este horario.";
                }

                if (valor2 == 1)
                {
                    ViewBag.advertencia3 = "La hora ingresada no es valida.";
                }

                if (valor == 1 || valor2 == 1 || valor3 == 1)
                {
                }
                else
                {
                    db.Turnos.Add(turno);
                    db.SaveChanges();
                    log.Info("Creacion de turno");
                    //int valor99 = 0;
                    //foreach (var item in repositoryatencion.List())
                    //{

                    //    if (valor99 < item.Id)
                    //    {
                    //        valor99 = item.Id;
                    //    }

                    //}
                    //repositoryatencion.Delete(valor99);
                    //valor99 = 0;
                    return(RedirectToAction("Index"));
                }
            }



            ViewBag.IdPaciente = new SelectList(db.Pacientes, "Id", "Nombre", turno.IdPaciente);
            return(View(turno));
        }