public IHttpActionResult PutGente(int id, Gente gente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gente.PerosnId)
            {
                return(BadRequest());
            }

            db.Entry(gente).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GenteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private void nudGente_ValueChanged(object sender, EventArgs e)
        {
            if (this.bar.Gente.Count < this.nudGente.Value)
            {
                short edad;

                Datos datos = new Datos();

                datos.txtDni.Enabled = false;

                datos.ShowDialog();

                if (!short.TryParse(datos.Edad, out edad))
                {
                    edad = 0;
                }

                Gente gen = new Gente(short.Parse(datos.Edad));

                if (!(this.bar + gen))
                {
                    this.nudGente.Value--;
                }
                else if (!string.IsNullOrEmpty(datos.Nombre))
                {
                    gen.Nombre = datos.Nombre;
                }
            }
            else if (this.bar.Gente.Count > this.nudGente.Value)
            {
                this.bar.Gente.Remove(this.bar.Gente.First());
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Gente gente)
        {
            if (id != gente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenteExists(gente.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gente));
        }
Beispiel #4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            short edadAux;
            int   dniAux;

            short.TryParse(this.txtEdad.Text, out edadAux);
            if (this.flag == "Empleado")
            {
                int.TryParse(this.txtDni.Text, out dniAux);
                this.nuevoEmpleado = new Empleado(this.txtNombre.Text, edadAux, dniAux);
                if (this.nuevoBar + this.nuevoEmpleado)
                {
                    MessageBox.Show("Se agrego un nuevo empleado", "Empleado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No se pudo agregar un nuevo empleado", "Empleado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (this.flag == "Gente")
            {
                this.nuevoGente = new Gente(this.txtNombre.Text, edadAux);
                if (this.nuevoBar + this.nuevoGente)
                {
                    MessageBox.Show("Se agrego una nueva persona", "Gente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No se pudo agregar una persona", "Gente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            this.Close();
        }
        /// <summary>
        /// Agrego empleado desde el NumericUpDown y elimino el primero de la lista
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void nudGente_ValueChanged(object sender, EventArgs e)
        {
            ControlPublicoForm form = new ControlPublicoForm();

            if (this.bar.Gente.Count < nudGente.Value)
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    short edad;
                    short.TryParse(form.Edad, out edad);
                    Gente gente   = new Gente(edad, form.Nombre);
                    bool  retorno = bar + gente;
                    if (retorno == true)
                    {
                        MessageBox.Show("Se ha agregado al cliente a la lista!", "Agregado.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("No se pudo agregar el cliente a la lista o ya se encuentra en la lista", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        nudGente.Value--;
                    }
                }
            }
            else if (nudGente.Value < 0)
            {
                nudGente.Value = 0;
            }
            else
            {
                bar.Gente.Remove(bar.Gente.First());
                MessageBox.Show("Se ha eliminado el primer cliente de la lista", "Eliminado.", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Gente gente = db.Gentes.Find(id);

            db.Gentes.Remove(gente);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
 public ActionResult Edit(Gente gente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gente));
 }
 public ActionResult Edit([Bind(Include = "PerosnId,Name,CovidCount")] Gente gente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gente));
 }
Beispiel #9
0
        //
        // GET: /Gente/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Gente gente = db.Gentes.Find(id);

            if (gente == null)
            {
                return(HttpNotFound());
            }
            return(View(gente));
        }
        public IHttpActionResult GetGente(int id)
        {
            Gente gente = db.Gentes.Find(id);

            if (gente == null)
            {
                return(NotFound());
            }

            return(Ok(gente));
        }
        public async Task <IActionResult> Create([Bind("Id,Nome")] Gente gente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gente));
        }
Beispiel #12
0
        public ActionResult Create(Gente gente)
        {
            if (ModelState.IsValid)
            {
                db.Gentes.Add(gente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gente));
        }
Beispiel #13
0
        //public string GetGentes()
        //{
        //    var data = db.Gentes.AsEnumerable();
        //    return JsonConvert.SerializeObject(data);
        //}

        // GET api/GenteApi/5
        public Gente GetGente(int id)
        {
            Gente gente = db.Gentes.Single(p => p.ID == id);

            if (gente == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(gente);
        }
        public ActionResult Create([Bind(Include = "PerosnId,Name,CovidCount")] Gente gente)
        {
            if (ModelState.IsValid)
            {
                db.Gentes.Add(gente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gente));
        }
        public IHttpActionResult PostGente(Gente gente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Gentes.Add(gente);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = gente.PerosnId }, gente));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gente gente = db.Gentes.Find(id);

            if (gente == null)
            {
                return(HttpNotFound());
            }
            return(View(gente));
        }
        public IHttpActionResult DeleteGente(int id)
        {
            Gente gente = db.Gentes.Find(id);

            if (gente == null)
            {
                return(NotFound());
            }

            db.Gentes.Remove(gente);
            db.SaveChanges();

            return(Ok(gente));
        }
Beispiel #18
0
        private Gente GenteNueva(string edad)
        {
            Gente nuevo;
            short edadAux;

            if (short.TryParse(edad, out edadAux))
            {
                nuevo = new Gente(edadAux);
                if (nuevo.Validar())
                {
                    return(nuevo);
                }
            }
            return(null);
        }
Beispiel #19
0
        // POST api/GenteApi
        public HttpResponseMessage PostGente(Gente gente)
        {
            if (ModelState.IsValid)
            {
                db.Gentes.InsertOnSubmit(gente);
                db.SubmitChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, gente);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = gente.ID }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        private void nudGente_ValueChanged(object sender, EventArgs e)
        {
            decimal numActual = nudGente.Value;

            if (cantidadGente <= numActual)
            {
                Gente gente = new Gente(50);
                if (bar + gente)
                {
                    cantidadGente = numActual;
                }
                else
                {
                    nudGente.Value = bar.Gente.Count;
                }
            }
        }
Beispiel #21
0
 private void btnAceptar_Click(object sender, EventArgs e)
 {
     if (this.tipo == typeof(Empleado))
     {
         if (EsDniValido() && EsEdadValida() && EsNombreValido())
         {
             Empleado empleado         = CrearEmpleado(Nombre, Dni, Edad);
             bool     seAgregoEmpleado = bar + empleado;
             if (seAgregoEmpleado)
             {
                 MessageBox.Show("Se agrego el empleado!", "Nuevo empleado.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Ocurrio un error. Verifique la edad. Edad minima: 22. Longitud minima nombre: 2", "Nuevo empleado.", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Verifique los datos para cargar el nuevo empleado", "Nuevo empleado.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         if (EsEdadValida())
         {
             Gente cliente         = CreanGente(Edad);
             bool  seAgregoCliente = bar + cliente;
             if (seAgregoCliente)
             {
                 MessageBox.Show("Se agrego el cliente!", "Nuevo Cliente.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Cupo maximo de clientes: 10.", "Nuevo Cliente.", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Verifique los datos para cargar el cliente. Edad minima: 19.", "Nuevo cliente.", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #22
0
        private void nudGente_ValueChanged(object sender, EventArgs e)
        {
            if (int.TryParse(nudGente.Value.ToString(), out int value))
            {
                if (value != 0 && value > 0)
                {
                    if (bar.Gente.Count < value)
                    {
                        FrmDatos     frm       = new FrmDatos();
                        DialogResult resultado = frm.ShowDialog();
                        if (resultado == DialogResult.OK)
                        {
                            if (frm.Edad > 0)
                            {
                                gente = new Gente(frm.Nombre, frm.Edad);
                            }
                            else
                            {
                                gente = new Gente(frm.Edad);
                            }

                            if (gente.Validar())
                            {
                                bool rta = bar + gente;
                                MessageBox.Show("Se AGREGO una gentuza!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("No cumple los requisitos!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        nudGente.Value = bar.Gente.Count;
                    }
                    else if (bar.Gente.Count > value)
                    {
                        FrmDatos frm = new FrmDatos();
                        bar.Gente.Remove(bar.Gente.First());
                        MessageBox.Show("Se QUITO una gentuza!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        nudGente.Value = bar.Gente.Count;
                    }
                }
            }
        }
Beispiel #23
0
 private void buttonAceptar_Click(object sender, EventArgs e)
 {
     if (this.tipo == typeof(Empleado))
     {
         Empleado empleado         = EmpleadoNuevo(Nombre, Edad, Dni);
         bool     empleadoAgregado = bar + empleado;
         if (empleadoAgregado)
         {
             this.Close();
         }
     }
     else if (this.tipo == typeof(Gente))
     {
         Gente gente         = GenteNueva(Edad);
         bool  genteAgregada = bar + gente;
         if (genteAgregada)
         {
             this.Close();
         }
     }
 }
Beispiel #24
0
        // PUT api/GenteApi/5
        public HttpResponseMessage PutGente(int id, Gente gente)
        {
            if (ModelState.IsValid && id == gente.ID)
            {
                db.Gentes.Attach(gente);

                try
                {
                    db.SubmitChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Beispiel #25
0
        // DELETE api/GenteApi/5
        public HttpResponseMessage DeleteGente(int id)
        {
            Gente gente = db.Gentes.Single(p => p.ID == id);

            if (gente == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.Gentes.DeleteOnSubmit(gente);

            try
            {
                db.SubmitChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, gente));
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            Bar bar = Bar.GetBar();

            Empleado e1 = new Empleado("Ailen", 30);
            Empleado e3 = new Empleado("Ailen", 30);
            Empleado e2 = new Empleado("Leonardo", 22, 1234);

            Gente g1 = new Gente(19);
            Gente g2 = new Gente(23);

            g2.Nombre = "Leonardo";
            Gente g3 = new Gente(17);

            g3.Nombre = "Ailen";
            Gente g4 = new Gente(90);
            Gente g5 = new Gente(23);
            Gente g6 = new Gente(24);

            if (bar + e1)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            if (bar + e2)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            if (bar + e3)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            if (bar + g1)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            if (bar + g2)
            {
                Console.WriteLine("Todo gud {0}", g2.Nombre);
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal {0}", g2.Nombre);
            }

            if (bar + g3)
            {
                Console.WriteLine("Todo gud {0}", g3.Nombre);
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal {0}", g3.Nombre);
            }

            if (bar + g4)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            if (bar + g5)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            if (bar + g6)
            {
                Console.WriteLine("Todo gud");
                Console.WriteLine(bar.ToString());
            }
            else
            {
                Console.WriteLine(" Todo mal");
            }

            Console.ReadKey();
        }
    void Start()
    {
        Ezombi = Random.Range(5, limitecreacion + 1);
        Ngente = limitecreacion - Ezombi;
        Ngente = Random.Range(0, Ngente + 1);

        for (int i = 0; i < Ezombi; i++)
        {
            colorzombie = Random.Range(0, 3);
            zombie z = new zombie(colorzombie);
        }



        //string[] names = new string[]
        //     {
        //          "stubbs",
        //          "rob",
        //          "white"
        //     };
        //for (int i = 0; i < names.Length; i++)
        //{
        //    zombie z = new zombie(names[i], Random.Range(10, 15));
        //    Debug.Log(z.name);
        //}



        string[] Nombre = new string[]
        {
            "stubbs",
            "rob",
            "toreto",
            "pequeño tim",
            "don carlos",
            "carlos 1",
            "carlos 2",
            "sergio",
            "stevan",
            "tu tia en tanga",
            "panzerotte del sena ",
            "cj",
            "hay te voy sam pedro",
            "san peludo",
            "alexianismo :v",
            "puto alexis",
            "jason",
            "andrey",
            "atreus",
            "artion",
            "kratos",
            "zeus",
            "loki",
            "puto el que lo lea",
            "wilson",
            "el brayan",
            "venites ",
            "sam pedro",
        };
        for (int i = 0; i < Ngente; i++)
        {
            //Gente z = new Gente(Nombre[i], Random.Range(0,9));
            //Debug.Log(z.Nombres);

            intNombre = Random.Range(0, 20);
            NNombre   = Nombre[intNombre];
            Nedad     = Random.Range(15, 100);

            Gente gentevivita = new Gente(NNombre, Nedad);


            Debug.Log(" hola mi nombre es " + NNombre + " y tengo " + Nedad);
        }
    }
Beispiel #28
0
    //"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    void Start()
    {
        // al momento de presionar  play en unity  el  crea a los zombies y  aldeanos y se va sumado ala  variable del limite
        //
        Numero_zombi = Random.Range(5, limite + 1);
        Numero_gente = limite - Numero_zombi;
        Numero_gente = Random.Range(0, Numero_gente + 1);

        for (int i = 0; i < Numero_zombi; i++) // usa los casos de  los colores  para los zombies hasta que se cumpla
        {
            colorzombie = Random.Range(0, 3);
            zombie z = new zombie(colorzombie);
        }



        // array para almacenar los datos de los nombre  de los aldeanos

        string[] Nombre = new string[]
        {
            "rodrigo",
            "robin",
            "torrez",
            "pequeñi",
            "don juan",
            "blue",
            "saltin",
            "sergio",
            "estevan",
            "tu tia en tanga",
            "tu colega ",
            "camilo",
            "crespos",
            "alexis",
            "hay te va sam pedro :v",
            "fly",
            "jason",
            "andrey",
            "atreus",
            "artion",
            "alegandra",
            "zeus",
            "mauricio",
            "puto el que lo lea",
            "el wilson bolso ",
            "el brayan",
            "el benites ",
            "carlos",
        };
        for (int i = 0; i < Numero_gente; i++) // genera a los aldenos  y su nombre y edad hasta que cumpla su condicion
        {
            intNombre   = Random.Range(0, 20);
            NNombre     = Nombre[intNombre];
            Numero_edad = Random.Range(15, 100);

            Gente genera_gente = new Gente(NNombre, Numero_edad);


            print("darmensaje " + " hola mi nombre es " + NNombre + " y tengo " + Numero_edad);
        }
    }