Exemplo n.º 1
0
        public IHttpActionResult PutMK_SCORE(int id, MK_SCORE mK_SCORE)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult PutVOTE_TO_AGENDA(int id, VOTE_TO_AGENDA vOTE_TO_AGENDA)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        public ActionResult Registrar_Contacto()
        {
            String mensaje_inserccion;

            try
            {
                String nombre   = Request.Form["nombre"].ToString();
                String telefono = Request.Form["telefono"].ToString();
                String email    = Request.Form["email"].ToString();

                contacto c = new contacto();
                c.nombre   = nombre;
                c.telefono = telefono;
                c.email    = email;
                conn.contacto.Add(c);
                conn.SaveChanges();
                mensaje_inserccion = "Contacto registrado Exitosamente";
            }
            catch (Exception ex)
            {
                mensaje_inserccion = "Error al registrar contacto " + ex.Message;
            }
            ViewData["mensaje"] = mensaje_inserccion;
            int cantidad_contactos = conn.contacto.Count();
            int cantidad_eventos   = conn.evento.Count();

            ViewData["cant_contactos"] = cantidad_contactos.ToString();
            ViewData["cant_eventos"]   = cantidad_eventos.ToString();

            return(View("Index"));
        }
 public ActionResult Edit([Bind(Include = "Email,Nome,Idade")] Pessoa pessoa)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pessoa).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pessoa));
 }
Exemplo n.º 5
0
        public IHttpActionResult PutITEM2AGENDA(int itemId, int agendaId, ITEM2AGENDA iTEM2AGENDA)
        {
            ITEM2AGENDA tmpITEM2AGENDA;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (itemId != iTEM2AGENDA.item || agendaId != iTEM2AGENDA.agenda)
            {
                return(BadRequest());
            }

            tmpITEM2AGENDA = db.ITEM2AGENDA.FirstOrDefault(e => e.item == itemId && e.agenda == agendaId);
            if (tmpITEM2AGENDA == null)
            {
                // if record not exist, we will crate it
                tmpITEM2AGENDA             = new ITEM2AGENDA();
                tmpITEM2AGENDA.item        = iTEM2AGENDA.item;
                tmpITEM2AGENDA.agenda      = iTEM2AGENDA.agenda;
                tmpITEM2AGENDA.description = iTEM2AGENDA.description;
                tmpITEM2AGENDA.opinion     = iTEM2AGENDA.opinion;
                tmpITEM2AGENDA.importance  = iTEM2AGENDA.importance;
                tmpITEM2AGENDA.lastUpdate  = DateTime.Now;

                db.Entry(tmpITEM2AGENDA).State = EntityState.Added;
            }
            else
            {
                tmpITEM2AGENDA.description = iTEM2AGENDA.description;
                tmpITEM2AGENDA.opinion     = iTEM2AGENDA.opinion;
                tmpITEM2AGENDA.importance  = iTEM2AGENDA.importance;
                tmpITEM2AGENDA.lastUpdate  = DateTime.Now;

                db.Entry(tmpITEM2AGENDA).State = EntityState.Modified;
            }
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ITEM2AGENDAExists(itemId, agendaId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Celular,Email,Direccion")] Contactos contactos)
        {
            if (ModelState.IsValid)
            {
                db.Contactos.Add(contactos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contactos));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "Id,mk_name")] MK mK)
        {
            if (ModelState.IsValid)
            {
                db.MK.Add(mK);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mK));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Casa,Cliente,Telefone,DataEntrada,DataSaida,HoraEntrada,HoraSaida")] Agenda agenda)
        {
            if (ModelState.IsValid)
            {
                db.agenda.Add(agenda);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agenda));
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Id,Nombre")] Departamento departamento)
        {
            if (ModelState.IsValid)
            {
                db.Departamento.Add(departamento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(departamento));
        }
Exemplo n.º 10
0
        public ActionResult Create(tbl1 tbl1)
        {
            if (ModelState.IsValid)
            {
                db.tbl1.Add(tbl1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl1));
        }
        public ActionResult Create([Bind(Include = "id_cliente,nm_cliente,ds_telefone")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                db.Clientes.Add(cliente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cliente));
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Id,party1")] PARTY pARTY)
        {
            if (ModelState.IsValid)
            {
                db.PARTY.Add(pARTY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pARTY));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "Id,name,description")] AGENDA aGENDA)
        {
            if (ModelState.IsValid)
            {
                db.AGENDA.Add(aGENDA);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aGENDA));
        }
Exemplo n.º 14
0
        public ActionResult Create([Bind(Include = "Email,Nome,Idade")] Pessoa pessoa)
        {
            if (ModelState.IsValid)
            {
                db.Pessoas.Add(pessoa);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pessoa));
        }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "Id,Evento1,Fecha,Hora")] Evento evento)
        {
            if (ModelState.IsValid)
            {
                db.Evento.Add(evento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(evento));
        }
Exemplo n.º 16
0
        public ActionResult Create([Bind(Include = "id_evento,nome_evt,data_evt,contato_evt")] Evento evento)
        {
            if (ModelState.IsValid)
            {
                db.Eventoes.Add(evento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(evento));
        }
Exemplo n.º 17
0
        public ActionResult Create([Bind(Include = "Id,Nome,Email")] Agenda agenda)
        {
            if (ModelState.IsValid)
            {
                db.Agenda.Add(agenda);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agenda));
        }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "Id,Nombre,Email,Celular,Direccion")] Usuario usuario)
        {
            if (ModelState.IsValid)
            {
                db.Usuario.Add(usuario);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(usuario));
        }
Exemplo n.º 19
0
        public ActionResult Create([Bind(Include = "Id,Nombre,FechaNacimiento,Departamento_Id")] Empleado empleado)
        {
            if (ModelState.IsValid)
            {
                db.Empleado.Add(empleado);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Departamento_Id = new SelectList(db.Departamento, "Id", "Nombre", empleado.Departamento_Id);
            return(View(empleado));
        }
Exemplo n.º 20
0
        public ActionResult Create([Bind(Include = "Id,Descripcion,FechaInicio,FechaFin,HoraInicio,HoraFin,Empleado_Id")] Tarea tarea)
        {
            if (ModelState.IsValid)
            {
                db.Tarea.Add(tarea);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Empleado_Id = new SelectList(db.Empleado, "Id", "Nombre", tarea.Empleado_Id);
            return(View(tarea));
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "id,idUsuario,nombreContacto,telefono,email,direccion")] Agenda agenda)
        {
            if (ModelState.IsValid)
            {
                db.Agenda.Add(agenda);
                db.SaveChanges();
                return(RedirectToAction("verAgenda"));
            }

            ViewBag.idUsuario = new SelectList(db.Usuario, "id", "usuario1", agenda.idUsuario);
            return(View(agenda));
        }
Exemplo n.º 22
0
        public ActionResult Create([Bind(Include = "Id,mk,score,volume,fromDate,toDate,agendaId")] MK_SCORE mK_SCORE)
        {
            if (ModelState.IsValid)
            {
                db.MK_SCORE.Add(mK_SCORE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.mk       = new SelectList(db.MK, "Id", "mk_name", mK_SCORE.mk);
            ViewBag.agendaId = new SelectList(db.AGENDA, "Id", "name", mK_SCORE.agendaId);
            return(View(mK_SCORE));
        }
Exemplo n.º 23
0
        public ActionResult Create([Bind(Include = "Id,mk,party,fromDate,toDate,knessetNumber")] MK_TO_PARTY mK_TO_PARTY)
        {
            if (ModelState.IsValid)
            {
                db.MK_TO_PARTY.Add(mK_TO_PARTY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.mk    = new SelectList(db.MK, "Id", "mk_name", mK_TO_PARTY.mk);
            ViewBag.party = new SelectList(db.PARTY, "Id", "party1", mK_TO_PARTY.party);
            return(View(mK_TO_PARTY));
        }
Exemplo n.º 24
0
        public static bool Excluir(Pessoa p)
        {
            try
            {
                AgendaEntities db = new AgendaEntities();
                Pessoa         pa = new Pessoa();

                pa = db.Pessoas.Find(p.Email);

                if (pa != null)
                {
                    db.Pessoas.Remove(pa);
                }
                else
                {
                    return(false);
                }

                db.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 25
0
        public static OperationResult Create(ContactoModel contacto)
        {
            try
            {
                #region Validaciones
                if (contacto == null) return new OperationResult() { Message = "El objeto Contacto viene vacío"};
                if (string.IsNullOrEmpty(contacto.Nombre)) return new OperationResult() { Message = "El nombre es requerido" };
                if (string.IsNullOrEmpty(contacto.ApellidoPaterno)) return new OperationResult() { Message = "El apellido paterno es requerido" };
                if (string.IsNullOrEmpty(contacto.Telefono)) return new OperationResult() { Message = "El teléfono es requerido" };
                if (contacto.Nombre.Length > 50) return new OperationResult() { Message = "El nombre debe tener 50 caracteres como máximo" };
                if (contacto.ApellidoPaterno.Length > 50) return new OperationResult() { Message = "El apellido debe tener 50 caracteres como máximo" };
                if (!string.IsNullOrEmpty(contacto.ApellidoMaterno))
                {
                    if (contacto.ApellidoMaterno.Length > 50) return new OperationResult() { Message = "El apellido debe tener 50 caracteres como máximo" };
                }     
                if (contacto.Telefono.Length > 16) return new OperationResult() { Message = "El teléfono debe tener 16 caracteres como máximo" };
                if (!string.IsNullOrEmpty(contacto.Direccion))
                {
                    if (contacto.Direccion.Length > 100) return new OperationResult() { Message = "La dirección debe tener 100 caracteres como máximo" };
                }                   

                var contactosTel = GetBy_Tel(contacto.Telefono);
                if (contactosTel.Any()) return new OperationResult() { Message = "El número de teléfono ya ha sido registrado anteriormente." };

                var contactosEmail = GetBy_Email(contacto.Email);
                if (contactosEmail.Any()) return new OperationResult() { Message = "El correo electrónico ya ha sido registrado anteriormente." };
                #endregion

                using (AgendaEntities dbContext = new AgendaEntities())
                {
                    dbContext.Contacto.Add(new Contacto() { 
                    
                        Activo = true,
                        ApellidoMaterno = contacto.ApellidoMaterno,
                        ApellidoPaterno =  contacto.ApellidoPaterno,
                        Direccion = contacto.Direccion,
                        Email = contacto.Email,
                        FechaCreacion = DateTime.Now,
                        Id = Guid.NewGuid(),
                        Nombre = contacto.Nombre,
                        Telefono = contacto.Telefono

                    });

                    dbContext.SaveChanges();

                    return new OperationResult() { Success = true };
                }
            }
            catch (Exception ex)
            {               
                return new OperationResult() { Message = ex.Message }; // Normalmente se manda un error genérico, pero se deja así por fines de que es una evaluación
            }
        }
Exemplo n.º 26
0
        public bool addTask(Tarea task)
        {
            var retorno = false;

            using (var conexion = new AgendaEntities())
            {
                conexion.Tareas.Add(task);
                conexion.SaveChanges();
                retorno = true;
            }
            return(retorno);
        }
Exemplo n.º 27
0
        public bool deletedTask(int ID)
        {
            var retorno = false;

            using (var conexion = new AgendaEntities())
            {
                var t = conexion.Tareas.FirstOrDefault(x => x.ID == ID);
                conexion.Tareas.Remove(t);
                conexion.SaveChanges();
                retorno = true;
            }
            return(retorno);
        }
Exemplo n.º 28
0
        public bool updateTask(int ID)
        {
            var retorno = false;

            using (var conexion = new AgendaEntities())
            {
                var t = conexion.Tareas.FirstOrDefault(x => x.ID == ID);
                t.estado = (t.estado) ? false : true;
                conexion.SaveChanges();
                retorno = true;
            }
            return(retorno);
        }
Exemplo n.º 29
0
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            AgendaEntities agenda   = new AgendaEntities();
            Usuarios       usuarios = new Usuarios();

            usuarios.Nome  = RegisterUser.UserName.ToString();
            usuarios.Email = RegisterUser.Email.ToString();
            usuarios.Senha = RegisterUser.Password.ToString();

            agenda.AddToUsuarios(usuarios);
            agenda.SaveChanges();

            Response.Redirect("Login.aspx");
        }
Exemplo n.º 30
0
        public ActionResult addAppointment([Bind(Include = "idAppointment,DateHour,idBroker,idCustomer")] Appointment appointment)
        {
            ViewBag.idBroker   = new SelectList(db.Brokers, "idBroker", "LastName", appointment.idBroker);
            ViewBag.idCustomer = new SelectList(db.Customers, "idCustomer", "LastName", appointment.idCustomer);
            Appointment test = db.Appointments.Where(x => x.idBroker == appointment.idBroker && x.DateHour == appointment.DateHour).FirstOrDefault();

            if (test == null) // Test si un courtier a déjà un rendez-vous !
            {
                if (ModelState.IsValid)
                {
                    db.Appointments.Add(appointment);
                    db.SaveChanges();
                    return(RedirectToAction("AppointmentList"));
                }
                else
                {
                    return(View(appointment));
                }
            }
            else
            {
                return(View("Already"));
            }
        }