public ActionResult CapturaCliente(Cliente cliente, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (cliente.idCliente != 0)
         {
             //Edicion
             cliente.idAsp = userId;
             cliente.datosCapturados = capturoDatos(cliente);
             cliente.facturacionCapturada = capturoDatosFac(cliente);
             _clientes.Editar(cliente);
         }
         else
         {
             //Nuevo
             cliente.datosCapturados = capturoDatos(cliente);
             cliente.idAsp = userId;
             cliente.facturacionCapturada = capturoDatosFac(cliente);
             _clientes.Agregar(cliente);
         }
         if (!string.IsNullOrEmpty(returnUrl))
         {
             return Redirect(returnUrl);
         }
         return RedirectToAction("MisDatos");
     }
     return View(cliente);
 }
 private bool capturoDatosFac(Cliente cliente)
 {
     if (string.IsNullOrEmpty(cliente.razonSocial)
         || string.IsNullOrEmpty(cliente.direccionFacturacionLinea1)
         || string.IsNullOrEmpty(cliente.direccionFacturacionLinea2)
         || string.IsNullOrEmpty(cliente.rfc))
     {
         return false;
     }
     else
     {
         return true;
     }
 }
 public JsonResult nombreDisponible(Cliente cliente)
 {
     var usuario = _clientes.Cargar(a => a.nombreUsuario == cliente.nombreUsuario && a.idAsp != userId).SingleOrDefault();
     if (usuario != null)
     {
         return Json(false, JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(true, JsonRequestBehavior.AllowGet);
     }
 }
 private bool capturoDatos(Cliente cliente)
 {
     if (string.IsNullOrEmpty(cliente.direccionEnvioLinea1)
         || string.IsNullOrEmpty(cliente.nombre)
         || string.IsNullOrEmpty(cliente.apPaterno)
         || string.IsNullOrEmpty(cliente.cp) || string.IsNullOrEmpty(cliente.ciudad) || string.IsNullOrEmpty(cliente.telefono))
     {
         return false;
     }
     else
     {
         return true;
     }
 }
 // GET: Clientes
 public ActionResult MisDatos(string returnUrl)
 {
     ViewBag.returnUrl = returnUrl;
     ViewBag.paises = paises;
     ViewBag.estados = estados;
     var cliente = _clientes.Cargar(a => a.idAsp == userId).SingleOrDefault();
     if (cliente == null)
     {
         var _cliente = new Cliente();
         return View(_cliente);
     }
     if (ControllerContext.IsChildAction)
     {
         return View("_datosUsuario", cliente);
     }
     return View(cliente);
 }