Esempio n. 1
0
        public async Task <ActionResult> Create(Veterinaria veterinaria)
        {
            //FileStream fs;
            var filename = System.IO.Path.Combine(_enviroment.ContentRootPath,
                                                  "wwwroot", "Uploads", "Banners", veterinaria.MyFile.FileName);

            await veterinaria.MyFile.CopyToAsync(
                /*fs =*/ new System.IO.FileStream(filename, System.IO.FileMode.Create));

            //fs.Close();
            using (var Client = new HttpClient())
            {
                veterinaria.Id        = int.Parse(HttpContext.Session.GetString("Id"));
                veterinaria.Imagen    = veterinaria.MyFile.FileName;
                veterinaria.UsuarioId = int.Parse(HttpContext.Session.GetString("Id"));
                Client.BaseAddress    = new Uri("https://localhost:44357/api/Veterinaria");
                var posjob = Client.PostAsJsonAsync <Veterinaria>("veterinaria", veterinaria);
                posjob.Wait();

                var postresult = posjob.Result;
                if (postresult.IsSuccessStatusCode)
                {
                    return(RedirectToAction("VIndex", "Home"));
                }
            }

            ModelState.AddModelError(string.Empty, "Ha ocurrido un error");
            return(View(veterinaria));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Veterinaria veterinaria = new Veterinaria();

            veterinaria.AddMascota(new Gato("Salem", new DateTime(1990, 01, 01)));
            veterinaria.AddMascota(new Perro("Fatiga", new DateTime(2005, 03, 05)));

            foreach (Mascota mascota in veterinaria.Mascotas)
            {
                Console.WriteLine(mascota.CalcularEdad());

                //if (mascota.GetType() == typeof(Gato))
                if (mascota is Gato)
                {
                    Gato gato = (Gato)mascota;
                    Console.WriteLine(gato.MostrarDatos());
                    Console.WriteLine(gato.SaltarSobreMicrofono());
                }
                else
                {
                    Console.WriteLine(mascota.MostrarDatos());
                }
            }

            Console.ReadKey();
        }
Esempio n. 3
0
        public async Task <ActionResult> Edit(Veterinaria veterinaria)
        {
            var filename = System.IO.Path.Combine(_enviroment.ContentRootPath,
                                                  "wwwroot", "Uploads", "Banners", veterinaria.MyFile.FileName);

            await veterinaria.MyFile.CopyToAsync(
                new System.IO.FileStream(filename, System.IO.FileMode.Create));

            using (var client = new HttpClient())
            {
                veterinaria.UsuarioId = int.Parse(HttpContext.Session.GetString("Id"));
                veterinaria.Imagen    = veterinaria.MyFile.FileName;
                client.BaseAddress    = new Uri("https://localhost:44357/api/Veterinaria");

                //HTTP POST
                var putTask = client.PutAsJsonAsync("?id=" + veterinaria.Id, veterinaria);
                putTask.Wait();

                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Detalles"));
                }
            }
            return(View(veterinaria));
        }
Esempio n. 4
0
        public void agendarTurno(Doctor doctor, int hora, Veterinaria veterinaria)
        {
            Turno turno = new Turno(doctor, hora, veterinaria, ultimoIndex);

            turnos.Add(turno);
            ultimoIndex++;
        }
        public async Task <IActionResult> Index(Login login, Veterinaria veterinaria, Usuario usuario)
        {
            var json = await client.GetStringAsync(url);

            var jsonV = await client.GetStringAsync(urlv);

            var Usuarios     = JsonConvert.DeserializeObject <List <Usuario> >(json);
            var Veterinarias = JsonConvert.DeserializeObject <List <Veterinaria> >(jsonV);
            var _Usuario     = Usuarios.FirstOrDefault(e => e.Email.Equals(login.Email) && e.Password.Equals(login.Password));
            var _Usuariov    = Veterinarias.FirstOrDefault(e => e.UsuarioId.Equals(_Usuario.Id));

            if (_Usuario != null && _Usuariov == null)
            {
                HttpContext.Session.SetString("Id", _Usuario.Id.ToString());
                return(RedirectToAction("Usuario"));
            }
            else if (_Usuario != null && _Usuariov != null)
            {
                HttpContext.Session.SetString("Id", _Usuariov.Id.ToString());
                return(RedirectToAction("Veterinaria"));
            }
            else if (_Usuario == null && _Usuariov == null)
            {
                login.status = false;
                return(View());
            }
            return(View());
        }
        static void Main(string[] args)
        {
            var veterinaria = new Veterinaria();

            Animal[] animales = { new Perro(), new Gato(), new Pato(), new Vaca(), new Chancho() };
            veterinaria.AceptarAnimales(animales);
            System.Console.ReadLine();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Veterinaria veterinaria = db.Veterinaria.Find(id);

            db.Veterinaria.Remove(veterinaria);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "Id,nombre,direccion,telefono")] Veterinaria veterinaria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(veterinaria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(veterinaria));
 }
Esempio n. 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Veterinaria veterinaria = db.Veterinarias.Find(id);

            veterinaria.fechaBaja       = System.DateTime.Now;
            db.Entry(veterinaria).State = EntityState.Modified;
            // db.Veterinarias.Remove(veterinaria);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
        public IActionResult AddVeterinaria(Veterinaria v)
        {
            if (ModelState.IsValid)
            {
                _context.Veterinarias.Add(v);
                _context.SaveChanges();

                return(RedirectToAction("Veterinarias"));
            }
            return(View(v));
        }
Esempio n. 11
0
        public ActionResult Create([Bind(Include = "Id,nombre,direccion,telefono")] Veterinaria veterinaria)
        {
            if (ModelState.IsValid)
            {
                db.Veterinarias.Add(veterinaria);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(veterinaria));
        }
Esempio n. 12
0
        public ActionResult Create(int?id)
        {
            Veterinaria veterinaria = null;

            if (id != null)
            {
                veterinaria = db.Veterinaria.Find(id);
                return(View(veterinaria));
            }

            return(View());
        }
        public async Task AddVeterinaria(Veterinaria veterinaria)
        {
            Expression <Func <Veterinaria, bool> > expression = item => item.Id == veterinaria.Id;
            var veterinarias = await _unitOfWork.VeterinariaRepository.FindByCondition(expression);

            if (veterinarias.Any(item => item.Id == veterinaria.Id))
            {
                throw new Exception("Este producto ya ha sido registrado");
            }


            await _unitOfWork.VeterinariaRepository.Add(veterinaria);
        }
Esempio n. 14
0
 public ActionResult DeleteConfirmed(int id)
 {
     try {
         Veterinaria veterinaria = db.Veterinarias.Find(id);
         db.Veterinarias.Remove(veterinaria);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View("ErrorDeleteRef", new HandleErrorInfo(ex, "Veterinarias", "Delete")));
     }
 }
Esempio n. 15
0
        // GET: Veterinarias/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Veterinaria veterinaria = db.Veterinarias.Find(id);

            if (veterinaria == null)
            {
                return(HttpNotFound());
            }
            return(View(veterinaria));
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            Veterinaria veterinaria = new Veterinaria();

            Perro a = new Perro();
            veterinaria.AceptarAnimal(a);

            Gato b = new Gato();
            veterinaria.AceptarAnimal(b);

            Perro c = new Perro();
            veterinaria.AceptarAnimal(c);

            veterinaria.HacerRuidos();
        }
Esempio n. 17
0
 public ActionResult Edit([Bind(Include = "Id,nombre,direccion,telefono,fechaBaja")] Veterinaria veterinaria)
 {
     if (ModelState.IsValid)
     {
         try {
             db.Entry(veterinaria).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             return(View("ErrorCreateDup", new HandleErrorInfo(ex, "Veterinarias", "Edit")));
         }
     }
     return(View(veterinaria));
 }
Esempio n. 18
0
        public ActionResult Create([Bind(Include = "Id,Rut,Nombre,Correo,Fono")] Veterinaria veterinaria)
        {
            if (ModelState.IsValid)
            {
                db.Veterinaria.Add(veterinaria);

                db.SaveChanges();

                return(RedirectToAction("Create", "Sucursals", new { id = db.Veterinaria.Find(veterinaria.Id).Id }));//Sucrusals/Create/11..
            }
            else
            {
                return(RedirectToAction("Create", "Sucursals"));
            }

            return(View(veterinaria));
        }
        public ActionResult guardarVeterinario(string nombre, string dir, string email, string pass)
        {
            Veterinaria vet = new Veterinaria();

            vet.nombre_veterinaria    = nombre;
            vet.direccion_veterinaria = dir;
            vet.email    = email;
            vet.password = pass;

            VeterinariaBusinessLayer vbl = new VeterinariaBusinessLayer();

            int respuesta;

            respuesta = vbl.insertarVet(vet);

            return(View("ventanaVeterinaria"));
        }
Esempio n. 20
0
        // GET: bY Id
        public ActionResult Edit(int id)
        {
            Veterinaria veterinaria = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44357/api/");
                var responseTask = client.GetAsync("veterinaria/" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readtask = result.Content.ReadAsAsync <Veterinaria>();
                    readtask.Wait();
                    veterinaria = readtask.Result;
                }
            }

            return(View(veterinaria));
        }
 public async Task UpdateVeterinaria(Veterinaria veterinaria)
 {
     await _unitOfWork.VeterinariaRepository.Update(veterinaria);
 }