示例#1
0
 public Boolean ComprobarNroDocumento(String nroDocumento)
 {
     if (ValidateFunctions.DocumentValidate(nroDocumento) && ValidateFunctions.OnlyNumbersValidate(nroDocumento))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 //FUNCION PARA VALIDAR CAMPOS NUMEROS COMO EDAD Y TELEFONO, DONDE SOLO DEBE CONTENER NUMEROS
 public bool ValidarEdadAndTelefono(String edad, String telefono)
 {
     if (ValidateFunctions.OnlyNumbersValidate(edad) && ValidateFunctions.OnlyNumbersValidate(telefono))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
 //FUNCION PARA VALIDAR EL DNI, DONDE SOLO SE DEBE INGRESAR NUMEROS Y DEBE TENER UN TAMAÑO DE 8 CARACTERES
 public bool ValidarNroDocumento(String nroDocumento)
 {
     if (ValidateFunctions.DocumentValidate(nroDocumento))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#4
0
 public bool validarCodigo(string idMedico)
 {
     if (ValidateFunctions.OnlyNumbersValidate(idMedico))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#5
0
 //FUNCION PARA VALIDAR LOS CAMPOS, DONDE SOLO SE DEBE INGRESAR LETRAS
 public bool ValidarDatosPersonales(String nombres, String apPaterno, String apMaterno)
 {
     if (ValidateFunctions.OnlyLettersValidate(nombres) && ValidateFunctions.OnlyLettersValidate(apPaterno) &&
         ValidateFunctions.OnlyLettersValidate(apMaterno))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#6
0
        public ActionResult Post(FormCollection form)
        {
            if (Session["userID"] == null)
            {
                return(RedirectToAction("Login", "User", new { redirectPage = "Post", redirectController = "JobAd" }));
            }

            _db = new renoRatorDBEntities();
            var newJobAd = new JobAd();

            newJobAd.address = new Address();

            TryUpdateModel(newJobAd, new string[] { "address.addressLine1", "address.addressLine2", "address.postalCode", "address.cityID" }, form.ToValueProvider());
            List <string> requiredFields = new List <string>()
            {
                "title", "address.addressLine1", "address.city.provinceID", "address.cityID", "priceRangeID", "description", "targetEndDate"
            };

            // check for null fields
            foreach (string field in requiredFields)
            {
                if (String.IsNullOrEmpty(form[field].Trim()))
                {
                    ModelState.AddModelError(field, "Field is required!");
                }
            }

            // validate other fields
            if (!ValidateFunctions.validPostalCode(form["address.postalCode"]))
            {
                ModelState.AddModelError("address.postalCode", "Postal code is invalid!");
            }
            if (!ValidateFunctions.validDateFormat(form["targetEndDate"]))
            {
                ModelState.AddModelError("targetEndDate", "Date format is invalid!");
            }

            try
            {
                newJobAd.address.addressLine1 = form["address.addressLine1"];
                newJobAd.address.addressLine2 = form["address.addressLine2"];
                newJobAd.address.postalCode   = form["address.postalCode"];
                newJobAd.address.cityID       = Convert.ToInt32(form["address.cityID"]);
                newJobAd.address.country      = "Canada";

                newJobAd.address.city.provinceID = Convert.ToInt32(form["address.city.provinceID"]);
                newJobAd.userID        = (int)Session["userID"];
                newJobAd.active        = true;
                newJobAd.priceRangeID  = Convert.ToInt32(form["priceRangeID"]);
                newJobAd.tags          = form["tags"].Replace(",", "||");
                newJobAd.description   = form["description"];
                newJobAd.targetEndDate = Convert.ToDateTime(form["targetEndDate"]);
                newJobAd.title         = form["title"];
            }
            catch { }



            if (ModelState.IsValid)
            {
                _db.AddToJobAds(newJobAd);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            // Otherwise, reshow form
            TryUpdateModel(newJobAd);
            populateDropdowns();
            return(View(newJobAd));
        }