public ActionResult Create([Bind(Include = "id,programa_id,cliente_id,horario_id,fecha_inicio,fecha_fin,created_at,updated_at,deleted_at")] programa_clientes programa_clientes, int clientId)
        {
            programa_clientes prg_cl = new programa_clientes();

            prg_cl.cliente_id   = clientId;
            prg_cl.horario_id   = programa_clientes.horario_id;
            prg_cl.programa_id  = programa_clientes.programa_id;
            prg_cl.fecha_inicio = programa_clientes.fecha_inicio;
            prg_cl.fecha_fin    = programa_clientes.fecha_fin;
            prg_cl.created_at   = DateTimeOffset.Now.DateTime;
            prg_cl.updated_at   = DateTimeOffset.Now.DateTime;

            db.programa_clientes.Add(prg_cl);

            try
            {
                db.SaveChanges();

                return(RedirectToAction("Create", "VentaUsuarios", new { clientId = clientId, feInit = prg_cl.fecha_inicio }));
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;

                return(View(clientId));
            }
        }
        public JsonResult CreateProspects(ProspectsReferredByClient rf)
        {
            prospectos p_1 = new prospectos();
            prospectos p_2 = new prospectos();

            p_1.nombres        = rf.p1_nombres;
            p_1.apellidos      = rf.p1_apellidos;
            p_1.telefono       = rf.p1_celular;
            p_1.email_personal = rf.p1_email;
            p_1.created_at     = DateTimeOffset.Now.Date;
            p_1.updated_at     = DateTimeOffset.Now.Date;

            p_2.nombres        = rf.p2_nombres;
            p_2.apellidos      = rf.p2_apellidos;
            p_2.telefono       = rf.p2_celular;
            p_2.email_personal = rf.p2_email;
            p_2.created_at     = DateTimeOffset.Now.Date;
            p_2.updated_at     = DateTimeOffset.Now.Date;

            List <prospectos> lstProspects = new List <prospectos>();

            lstProspects.Add(p_1);
            lstProspects.Add(p_2);

            db.prospectos.Add(lstProspects[0]);
            int c = db.SaveChanges();

            Dictionary <string, object> js = new Dictionary <string, object>();

            if (c > 0)
            {
                js.Add("message", "Se han creado " + c.ToString() + " prospectos.");
                js.Add("status", HttpStatusCode.OK);
                js.Add("p1_id", p_1.id);
                /*js.Add("p2_id", p_2.id);*/

                return(Json(js, JsonRequestBehavior.AllowGet));
            }

            js.Add("message", "Falló la inserción de datos.");
            js.Add("status", HttpStatusCode.Conflict);


            return(Json(js, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public JsonResult AddNota(Nota data)
        {
            clientes_notas nota            = new clientes_notas();
            Dictionary <string, object> js = new Dictionary <string, object>();
            string html = "";


            nota.usuarioId  = (int)Session["UserId"];
            nota.idCliente  = data.cliente_id;
            nota.nota       = data.nota;
            nota.created_at = DateTimeOffset.Now.DateTime;
            nota.updated_at = DateTimeOffset.Now.DateTime;
            nota.usuarios   = db.usuarios.Where(u => u.id == nota.usuarioId).FirstOrDefault();

            db.clientes_notas.Add(nota);
            int results = db.SaveChanges();

            if (results > 0)
            {
                html += "<div class='client-notes-item'>";
                html += "<img src='" + nota.usuarios.getFoto() + "' class='img-circle pull-left' width='60' alt='' />";
                html += "<div class='pull-right'>" + nota.created_at + "</div>";
                html += "<h3>" + nota.usuarios.nombres + " " + nota.usuarios.apellidos + "</h3>";
                html += "<p>" + nota.nota + "</p>";
                html += "</div>";

                js.Add("state", "success");
                js.Add("html", html);
            }
            else
            {
                js.Add("state", "error");
                js.Add("message", "Error en la inserción");
            }

            return(Json(js, JsonRequestBehavior.AllowGet));
        }