public async Task <IActionResult> PutMascotasVacunas(int id, [FromBody] MascotasVacunas mascotasvacunas)
        {
            Mascotas mascota = await _context.Mascotas.FirstOrDefaultAsync(u => u.Id == mascotasvacunas.MascotaId);

            if (!_permissions.isOwnerOrAdmin(this.User, mascota.idUsuario))
            {
                return(Forbid());
            }

            if (id != mascotasvacunas.Id)
            {
                return(BadRequest());
            }

            _context.Entry(mascotasvacunas).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MascotasVacunasExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public IActionResult Delete(int id)
        {
            bool error = false;

            if (id == 0)
            {
                error = false;
            }
            else
            {
                try
                {
                    Mascotas mascota = (from m in context.Mascotas
                                        where m.IdMascotas == id
                                        select m).FirstOrDefault <Mascotas>();
                    if (mascota == null)
                    {
                        return(new JsonResult(new { Status = "Fail" }));
                    }
                    context.Mascotas.Remove(mascota);
                    context.SaveChanges();
                }catch (Exception ex)
                {
                    error = true;
                    Console.WriteLine(ex);
                }
            }
            var Result = new { Status = !error ? "Success" : "Fail" };

            return(new JsonResult(Result));
        }
Esempio n. 3
0
        public MascotaDTO CrearMascota(MascotaDTO mascotaDTO)
        {
            try
            {
                using (HuellitasContext context = new HuellitasContext())
                {
                    Mascotas mascota = new Mascotas()
                    {
                        color  = mascotaDTO.ColorMascota,
                        edad   = mascotaDTO.EdadMascota,
                        nombre = mascotaDTO.NombreMascota,
                        raza   = mascotaDTO.RazaMascota,
                        tipo   = mascotaDTO.TipoMascota
                    };

                    context.Mascotas.Add(mascota);
                    context.SaveChanges();

                    mascotaDTO.IdMascota = context.Mascotas.Max(x => x.id);
                }

                mascotaDTO.Estado = Status.Success;
            }
            catch (Exception)
            {
                mascotaDTO.Estado = Status.Error;
                mascotaDTO.Msg    = "Error en el servidor";
            }
            return(mascotaDTO);
        }
Esempio n. 4
0
 public bool ActualizarMascotas(Mascotas mascota)
 {
     try
     {
         var consultar = (from m in bd.Mascotas where m.ID_mascota == mascota.ID_mascota select m).First();
         consultar.ID_mascota             = mascota.ID_mascota;
         consultar.Cedula_usuario         = mascota.Cedula_usuario;
         consultar.Tipo_documento_usuario = mascota.Tipo_documento_usuario;
         consultar.Nombre             = mascota.Nombre;
         consultar.Raza               = mascota.Raza;
         consultar.Especie            = mascota.Especie;
         consultar.Color              = mascota.Color;
         consultar.Sexo               = mascota.Sexo;
         consultar.Señas_particulares = mascota.Señas_particulares;
         consultar.Fecha_nacimiento   = mascota.Fecha_nacimiento;
         consultar.ID_estado_mascota  = mascota.ID_estado_mascota;
         bd.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            MascotaDAO mascotaDAO = new MascotaDAO();
            Mascotas   mascotaDTO = new Mascotas();

            mascotaDTO.ID_mascota             = (int.Parse(Session["idMascotaActualizar"].ToString()));
            mascotaDTO.Tipo_documento_usuario = (Session["tipoDocBusquedaPerfilAdmin"].ToString());
            mascotaDTO.Cedula_usuario         = (int.Parse(Session["numeroDocBusquedaPerfilAdmin"].ToString()));
            mascotaDTO.Nombre             = txtNombreMascota.Text;
            mascotaDTO.Especie            = txtEspecie.Text;
            mascotaDTO.Raza               = txtRazaMascota.Text;
            mascotaDTO.Color              = txtColorMascota.Text;
            mascotaDTO.Sexo               = ddlSexoMascota.SelectedValue;
            mascotaDTO.Señas_particulares = txtSeñasMascota.Text;
            mascotaDTO.Fecha_nacimiento   = ClFechaNacimiento.SelectedDate;
            if (rbEstadoMascota.SelectedItem.Value.ToString() == "Activo")
            {
                mascotaDTO.ID_estado_mascota = 1;
            }
            else
            {
                mascotaDTO.ID_estado_mascota = 2;
            }

            bool resultado = mascotaDAO.ActualizarMascotas(mascotaDTO);

            if (resultado == true)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alarm", "update_success_modal()", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alarm", "update_fail_modal()", true);
            }
        }
        static void Main(string[] args)
        {
            Mascotas        mascota1 = new Mascotas();
            FileStream      fs;
            BinaryFormatter formatter = new BinaryFormatter();
            const string    ARCHIVO   = "mascota.bin";

            try
            {
                Console.Write("Nombre: ");
                mascota1.nombre = Console.ReadLine();
                Console.Write("Especie: ");
                mascota1.especie = Console.ReadLine();
                Console.Write("Sexo: ");
                mascota1.sexo = Console.ReadLine();
                Console.Write("Edad: ");
                mascota1.edad = Convert.ToInt32(Console.ReadLine());
                fs            = new FileStream(ARCHIVO, FileMode.Create, FileAccess.Write);
                formatter.Serialize(fs, mascota1);
                fs.Close();
            }
            catch (Exception)
            {
                Console.WriteLine("Ocurrio un problema con la serializacion...");
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Mascotas        mascota = new Mascotas();
            FileStream      stream;
            BinaryFormatter format = new BinaryFormatter();

            try
            {
                Console.WriteLine("ESTRUCTURA DE MASCOTAS");
                Console.WriteLine();
                Console.Write("Nombre: ");
                mascota.nombre = Console.ReadLine();
                Console.Write("Especie: ");
                mascota.especie = Console.ReadLine();
                Console.Write("Raza: ");
                mascota.raza = Console.ReadLine();
                Console.Write("Sexo: ");
                mascota.sexo = Console.ReadLine();
                Console.Write("Edad (años): ");
                mascota.setEdad(Convert.ToInt32(Console.ReadLine()));
                stream = new FileStream("mascotas.bin", FileMode.Create, FileAccess.Write);
                format.Serialize(stream, mascota);
                stream.Close();
                Console.WriteLine();
                Console.WriteLine("La mascota fue almacenada con éxito c:");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Cliente clienteUno = new Cliente("nicolas", "letticugna", "Juan b justo 8112", "555-5555");

            /*  clienteUno.CambiarNombre("nicolas");
             * clienteUno.CambiarApellido("letticugna");
             * clienteUno.CambiarDomicilio("Juan b justo 8112  - CABA");
             * clienteUno.CambiarTelefono("555-5555");*/

            string clienteCompleto = clienteUno.obtenerCliente();

            System.Console.WriteLine(clienteCompleto);



            Mascotas mascotaUno = new Mascotas("Bob", "Caniche-Cocker", "15-06-17", "ssa-s-ss");

            /*  clienteUno.CambiarNombre("nicolas");
             * clienteUno.CambiarApellido("letticugna");
             * clienteUno.CambiarDomicilio("Juan b justo 8112  - CABA");
             * clienteUno.CambiarTelefono("555-5555");*/

            string mascotaCompleto = mascotaUno.obtenerMascota();

            System.Console.WriteLine(mascotaCompleto);
        }
Esempio n. 9
0
        public IActionResult Post([FromBody] Mascotas value)
        {
            bool error = false;

            if (validar_campos(value.Nombre, value.Edad, value.Tipo, value.Raza, value.Descripcion))
            {
                error = true;
            }
            else
            {
                value.Nombre      = WebUtility.HtmlEncode(value.Nombre);
                value.Tipo        = WebUtility.HtmlEncode(value.Tipo);
                value.Raza        = WebUtility.HtmlEncode(value.Raza);
                value.Descripcion = WebUtility.HtmlEncode(value.Descripcion);

                try
                {
                    context.Mascotas.Add(value);
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    error = true;
                    Console.WriteLine(ex);
                }
            }

            var Result = new { Status = !error ? "Success" : "Fail" };

            return(new JsonResult(Result));
        }
Esempio n. 10
0
        protected void btnCrear_Click(object sender, EventArgs e)
        {
            Mascotas   mascotaDTO = new Mascotas();
            MascotaDAO mascotaDAO = new MascotaDAO();

            mascotaDTO.Tipo_documento_usuario = txtTipoDoc.Text;
            mascotaDTO.Cedula_usuario         = int.Parse(txtNumeroDoc.Text);
            mascotaDTO.Nombre             = txtNombre.Text;
            mascotaDTO.Raza               = txtRaza.Text;
            mascotaDTO.Especie            = txtEspecie.Text;
            mascotaDTO.Color              = txtColor.Text;
            mascotaDTO.Sexo               = ddlSexoMascota.SelectedValue;
            mascotaDTO.Señas_particulares = txtSeñas.Text;
            mascotaDTO.Fecha_nacimiento   = ClFechaNacimiento.SelectedDate;
            if (rbEstadoMascota.SelectedItem.Value.ToString() == "Activo")
            {
                mascotaDTO.ID_estado_mascota = 1;
            }
            else if (rbEstadoMascota.SelectedItem.Value.ToString() == "Inactivo")
            {
                mascotaDTO.ID_estado_mascota = 2;
            }


            bool registrado = mascotaDAO.RegistrarMascotas(mascotaDTO);

            if (registrado == true)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alarm", "create_success_modal()", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alarm", "create_fail_modal()", true);
            }
        }
Esempio n. 11
0
        public ActionResult DeleteConfirmed(int id)
        {
            Mascotas mascotas = db.Mascotas.Find(id);

            db.Mascotas.Remove(mascotas);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 12
0
        /*Alta Mascota*/
        public bool altaMascota(string nombre, string especie, string raza, string sexo, DateTime fechaNacimiento, string foto)
        {
            bool alta = false;

            Mascotas.Add(new Mascota(nombre, especie, raza, sexo, fechaNacimiento, foto));
            alta = true;
            return(alta);
        }
Esempio n. 13
0
        public ActionResult adoptado(int id, int rid)
        {
            Mascotas mascotas = db.Mascotas.Find(id);

            mascotas.Status = 4;
            db.SaveChanges();
            return(RedirectToAction("Details", "Usuarios", new { id = rid }));
        }
Esempio n. 14
0
        // POST: Mascotas/Delete/5
        public ActionResult Borrar(int id, int rid)
        {
            Mascotas mascotas = db.Mascotas.Find(id);

            db.Mascotas.Remove(mascotas);
            db.SaveChanges();
            return(RedirectToAction("Details", "Usuarios", new { id = rid }));
        }
Esempio n. 15
0
 public ActionResult Edit([Bind(Include = "Id,Animal,Raza,Ubicacion,Sexo,Descripcion,Vacunas,Edad,Status")] Mascotas mascotas)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mascotas).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mascotas));
 }
Esempio n. 16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         MascotaDAO mascotaDAO = new MascotaDAO();
         Mascotas   mascotaDTO = mascotaDAO.ConsultaPorId(int.Parse(Session["idMascotaActualizar"].ToString()));
         txtIdMascota.Text     = mascotaDTO.ID_mascota.ToString();
         txtNombreMascota.Text = mascotaDTO.Nombre.ToString();
         // agregar los demas campos que deseo actualizar
     }
 }
Esempio n. 17
0
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            MascotaDAO mascotaDAO = new MascotaDAO();
            Mascotas   mascotaDTO = new Mascotas();

            mascotaDTO.ID_mascota = int.Parse(txtIdMascota.Text);
            mascotaDTO.Nombre     = txtNombreMascota.Text;
            // igual con todos los atributos
            mascotaDAO.ActualizarMascotas(mascotaDTO);
            Response.Redirect("BusquedaUsuarioAdmin.aspx");
        }
        public async Task <ActionResult <Mascotas> > PostMascotas(Mascotas mascotas)
        {
            if (!_permissions.isAdmin(this.User))
            {
                mascotas.idUsuario = _permissions.getUserId(this.User);
            }
            _context.Mascotas.Add(mascotas);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 19
0
 public string RegistrarMascotas(Mascotas mascota)
 {
     try
     {
         bd.Mascotas.InsertOnSubmit(mascota);
         bd.SubmitChanges();
         return("La mascota se ha registrado correctamente");
     }
     catch (Exception ex)
     {
         return("No se pudo registrar la mascota" + ex.Message);
     }
 }
Esempio n. 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MascotaDAO mascotaDAO = new MascotaDAO();
                Mascotas   mascotaDTO = mascotaDAO.ConsultaPorId(int.Parse(Session["idMascotaEscogidaDoctor"].ToString()));

                lblNombreMascota.Text = ("Hola! soy" + " " + mascotaDTO.Nombre);
                var genero = mascotaDTO.Sexo.ToLower() == "m" ? "Masculino" : "Femenino";
                lblTexto.Text = ("Soy un" + " " + mascotaDTO.Especie + " de Raza" + " " + mascotaDTO.Raza + "; Y soy de Sexo" + " " + genero + " . Naci el" + " " + mascotaDTO.Fecha_nacimiento.ToString("dd/MM/yyyy") + " y mi dueño se llama" + " " + mascotaDTO.Usuarios.Nombres + " " + mascotaDTO.Usuarios.Apellidos);
                CargarGrilla();
            }
        }
Esempio n. 21
0
        public ActionResult Crear(Mascotas nuevaMascota)
        {
            if (ModelState.IsValid)
            {
                db.mascotas.Add(nuevaMascota);

                db.SaveChanges();

                return(RedirectToAction("Lista"));
            }
            ViewBag.MensajeError = "Hubo un Error, Revise los Datos";
            return(View());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MascotaDAO mascotaDAO = new MascotaDAO();
            Mascotas   mascotaDTO = mascotaDAO.ConsultaPorId(int.Parse(Session["idMascotaVer"].ToString()));

            txtNombreMascota.Text     = mascotaDTO.Nombre.ToString();
            txtEspecieMascota.Text    = mascotaDTO.Especie.ToString();
            txtRazaMascota.Text       = mascotaDTO.Raza.ToString();
            txtColorMascota.Text      = mascotaDTO.Color.ToString();
            txtSexoMascota.Text       = mascotaDTO.Sexo.ToString();
            txtSeñasParticulares.Text = mascotaDTO.Señas_particulares.ToString();
            txtFechaNacimiento.Text   = mascotaDTO.Fecha_nacimiento.ToString();
            txtEstado.Text            = mascotaDTO.Estados.Descripcion;
        }
Esempio n. 23
0
 public bool RegistrarMascotas(Mascotas mascota)
 {
     try
     {
         bd.Mascotas.InsertOnSubmit(mascota);
         bd.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Console.Write(ex.Message);
         return(false);
     }
 }
        public async Task <ActionResult <MascotasVacunas> > PostMascotasVacunas(MascotasVacunas mascotasvacunas)
        {
            Mascotas mascota = await _context.Mascotas.FirstOrDefaultAsync(u => u.Id == mascotasvacunas.MascotaId);

            if (!_permissions.isAdmin(this.User))
            {
                mascota.idUsuario = _permissions.getUserId(this.User);
            }
            _context.MascotasVacunas.Add(mascotasvacunas);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Esempio n. 25
0
        // GET: Mascotas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mascotas mascotas = db.Mascotas.Find(id);

            if (mascotas == null)
            {
                return(HttpNotFound());
            }
            return(View(mascotas));
        }
Esempio n. 26
0
        public MascotaDTO UpdateMascota(MascotaDTO mascota)
        {
            try
            {
                using (HuellitasContext context = new HuellitasContext())
                {
                    Mascotas m = context.Mascotas.Where(x => x.id == mascota.IdMascota).First();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(mascota);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         MascotaDAO mascotaDAO = new MascotaDAO();
         Mascotas   mascotaDTO = mascotaDAO.ConsultaPorId(int.Parse(Session["idMascotaActualizar"].ToString()));
         txtNombreMascota.Text          = mascotaDTO.Nombre;
         txtEspecie.Text                = mascotaDTO.Especie;
         txtRazaMascota.Text            = mascotaDTO.Raza;
         txtColorMascota.Text           = mascotaDTO.Color;
         ddlSexoMascota.SelectedValue   = mascotaDTO.Sexo;
         ClFechaNacimiento.SelectedDate = (DateTime)mascotaDTO.Fecha_nacimiento;
         txtSeñasMascota.Text           = mascotaDTO.Señas_particulares;
         rbEstadoMascota.SelectedIndex  = mascotaDTO.ID_estado_mascota == 1 ? 0 : 1;
     }
 }
Esempio n. 28
0
        public ActionResult Create([Bind(Include = "Id,Animal,Raza,Ubicacion,Sexo,Descripcion,Vacunas,Edad,Status")] Mascotas mascotas, HttpPostedFileBase image1)
        {
            var db = new mascotasEntities1();

            if (image1 != null)
            {
                mascotas.Imagen = new byte[image1.ContentLength];
                image1.InputStream.Read(mascotas.Imagen, 0, image1.ContentLength);
            }

            if (ModelState.IsValid)
            {
                db.Mascotas.Add(mascotas);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mascotas));
        }
        public async Task <ActionResult <MascotasVacunas> > DeleteMascotasVacunas(int id)
        {
            var mascotasvacunas = await _context.MascotasVacunas.FindAsync(id);

            if (mascotasvacunas == null)
            {
                return(NotFound());
            }
            Mascotas mascota = await _context.Mascotas.FirstOrDefaultAsync(u => u.Id == mascotasvacunas.MascotaId);

            if (!_permissions.isOwnerOrAdmin(this.User, mascota.idUsuario))
            {
                return(Forbid());
            }

            _context.MascotasVacunas.Remove(mascotasvacunas);
            await _context.SaveChangesAsync();

            return(Ok());
        }
        public async Task <ActionResult <Reservas> > PostReserva(Reservas reservas)
        {
            if (!_permissions.isAdmin(this.User))
            {
                reservas.UsuarioId = _permissions.getUserId(this.User);
            }
            _context.Reservas.Add(reservas);

            Mascotas mascota = await _context.Mascotas.FirstOrDefaultAsync(e => e.Id == reservas.MascotaId);

            Usuarios usu = _context.Usuarios.FirstOrDefault(u => u.Id == reservas.UsuarioId);
            await _context.SaveChangesAsync();

            DateTime fechaHoy = DateTime.Now.Date;


            _log.LogInformation("enviando mail");
            if (fechaHoy.CompareTo(reservas.FechaAtencion.Date) == 0)
            {
                _log.LogInformation("Fecha Correcta " + fechaHoy.ToString());
                var nombreMascota = mascota.Nombre;
                var cliente       = usu.Apellido + ", " + usu.Nombre;
                var mail          = usu.Email;
                var telefono      = usu.Telefono;
                var fecha         = reservas.FechaAtencion.Day.ToString().PadLeft(2, '0') + "/" + reservas.FechaAtencion.Month.ToString().PadLeft(2, '0') + "/" + reservas.FechaAtencion.Year.ToString();

                var hora   = reservas.HoraAtencion;
                var motivo = reservas.Motivo;
                var body   = "<table style='width: 100%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000'><td >Se ha registrado un turno para el día <b>" + fecha + " a las " + hora + " hs</b></td></tr><tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><td>Nombre de la Mascota <b>" + nombreMascota + "</b></td></tr><tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><td>Nombre del Cliente <b>" + cliente + "</b></td></tr>  </tr><tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><td>Telefono del Cliente <b>" + telefono + "</b></td></tr> <tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><td>Mail del Cliente <b>" + mail + "</b></td></tr> <tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><td >Motivo de la Consulta</td></tr><tr style='width: 50%;font-family:Verdana;font-size:12px;text-align:left;color: #000000;'><td>" + motivo + "</td></tr></table>";

                AppSettings appSettings = new AppSettings();
                _configuration.GetSection("AppSettings").Bind(appSettings);
                await _mailService.sendReservaMail(body, appSettings.mailVeterinario, _log);

                _log.LogInformation("mail enviado a: " + appSettings.mailVeterinario);
            }



            return(Ok());
        }