Exemple #1
0
        public ActionResult Edit(FormCollection form)
        {
            plantillaEmail plantilla = null;

            try
            {
                if (ModelState.IsValid)
                {
                    plantilla = db.plantillaEmail.Find(Convert.ToInt32(form["codigo"]));

                    plantilla.asunto      = form["asunto"];
                    plantilla.descripcion = form["descripcion"];
                    plantilla.cuerpo      = form["cuerpo"];
                    plantilla.sector      = User.IsInRole("AdministradorEmpresas") == true ? (int)Sectores.Empresas : User.IsInRole("AdministradorGraduado") == true ? (int)Sectores.Graduados : (int)Sectores.Idiomas;
                    db.SaveChanges();
                    return(Json(new { ok = true }));
                    //return RedirectToAction("Index");
                }
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                ViewBag.ErrorMessage = string.Format(Strings.ErrorIntentarInsertarRegistro, e.Message.Replace(Strings.TheStatementHasBeenTerminated, ""));
                return(View());
            }

            return(View("Edit", plantilla));
        }
Exemple #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                plantillaEmail plantilla = db.plantillaEmail.Find(id);

                db.plantillaEmail.Remove(plantilla);

                if (db.SaveChanges() > 0)
                {
                    return(Json(new { ok = true }));
                }
                else
                {
                    return(Json(new { error = true }));
                }
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                ViewBag.ErrorMessage = string.Format(Strings.ErrorIntentarInsertarRegistro, e.Message.Replace(Strings.TheStatementHasBeenTerminated, ""));
                return(View());
            }
        }
Exemple #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string callback = Request.Params["callback"];

            if (string.IsNullOrEmpty(callback))
            {
                callback = "AjaxOk";
            }
            //var curso = new curso();
            ViewBag.modo     = "Edit";
            ViewBag.Callback = callback;

            plantillaEmail plantillaEmail = db.plantillaEmail.Find(id);

            if (plantillaEmail == null)
            {
                return(HttpNotFound());
            }
            return(View("Edit", plantillaEmail));
        }
Exemple #4
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            plantillaEmail plantillaEmail = db.plantillaEmail.Find(id);

            if (plantillaEmail == null)
            {
                return(HttpNotFound());
            }
            return(View(plantillaEmail));
        }
Exemple #5
0
        public ActionResult Create(FormCollection form)
        {
            plantillaEmail plantilla = new plantillaEmail();

            plantilla.asunto      = form["asunto"];
            plantilla.descripcion = form["descripcion"];
            plantilla.cuerpo      = form["cuerpo"];
            ViewBag.mensaje       = plantilla.cuerpo;
            plantilla.sector      = User.IsInRole("AdministradorEmpresas") == true ? (int)Sectores.Empresas : User.IsInRole("AdministradorGraduado") == true ? (int)Sectores.Graduados : (int)Sectores.Idiomas;
            try
            {
                if (ModelState.IsValid)
                {
                    #region Palabras aceptadas

                    List <string> listado = new List <string>();

                    listado.Add("%NOMBRE%");
                    listado.Add("%APELLIDO%");
                    listado.Add("%DOCUMENTO%");
                    listado.Add("%SEDE%");
                    listado.Add("%TIPO_CURSO%");
                    listado.Add("%CURSO%");
                    listado.Add("%DIA_HORARIO%");
                    listado.Add("%AULA%");
                    listado.Add("%FECHA_INICIO%");
                    listado.Add("%NRO_CUOTA%");
                    listado.Add("%TOTAL_CUOTAS%");
                    listado.Add("%IMPORTE%");
                    listado.Add("%IMPORTE2%");
                    listado.Add("%FECHA_VENCIMIENTO%");
                    listado.Add("%FECHA_VENCIMIENTO2%");

                    #endregion

                    //Patron
                    Regex           rgx     = new Regex(@"%([A-Z])\w+%", RegexOptions.IgnoreCase);
                    MatchCollection matches = rgx.Matches(form["cuerpo"]);
                    //Si encontro coincidencias
                    if (matches.Count > 0)
                    {
                        //Pregunto por cada una para chequear que solo se acepten las del listado
                        foreach (Match match in matches)
                        {
                            if (!listado.Contains(match.ToString()))
                            {
                                ViewBag.ErrorMessage += string.Format("Se detecto que " + match.ToString() + " no existe en el listado de palabras aceptadas, revise el cuerpo del correo e intente nuevamente.") + Environment.NewLine;
                            }
                        }
                    }

                    if (ViewBag.ErrorMessage == null)
                    {
                        db.plantillaEmail.Add(plantilla);
                        db.SaveChanges();
                        return(Json(new { ok = true }));
                    }
                }
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                ViewBag.ErrorMessage = string.Format(Strings.ErrorIntentarInsertarRegistro, e.Message.Replace(Strings.TheStatementHasBeenTerminated, ""));
            }

            return(PartialView(plantilla));
        }