Exemplo n.º 1
0
        public ActionResult Create(HttpPostedFileBase file, Cliente cliente/*, HttpPostedFileBase file*/)
        {
            if (ModelState.IsValid)
            {
                //file.SaveAs(Path.Combine(Url.Content("/Content/"), Path.GetFileName(file.FileName)));
                //if (file.ContentLength > 0)
                //{
                //    var fileName = Path.GetFileName(file.FileName);
                //    var path = Path.Combine(Server.MapPath("~/Content/"), file.FileName);
                //    file.SaveAs(path);
                //}

                // verifico q el nuevo cliente no este en la db
                var valid_cliente = db.Cliente.SingleOrDefault(c => c.Identificacion == cliente.Identificacion);
                if (valid_cliente == null)
                {
                    try {
                        db.Cliente.AddObject(cliente);
                        db.SaveChanges();
                        // consulto por el id del cliente
                        Cliente current_client = db.Cliente.SingleOrDefault(c =>
                            c.Identificacion == cliente.Identificacion);
                        ////obtengo el id del cliente 'lo necesito en reserva'
                        ClienteController.ID_Cliente = current_client.ClienteID;
                        return PartialView("_Cliente_registrado", cliente);
                    }catch(Exception e){
                        ViewBag.errorCreate = e.ToString();
                    }
                }
                else {
                    ViewBag.cliente_registrado = "El Cliente con numero de Identificacion " + cliente.Identificacion.ToString() +" ya se encuentra en la Base De Datos, ingrese nuevamente la Identificacion en el campo 'Cedula del Titular' y verifiquela; asi lograra cargar la informacion de este Cliente..! ";
                }
            }
            //return PartialView("_test", cliente);
            return PartialView(cliente);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Crear un nuevo objeto Cliente.
 /// </summary>
 /// <param name="clienteID">Valor inicial de la propiedad ClienteID.</param>
 /// <param name="identificacion">Valor inicial de la propiedad Identificacion.</param>
 public static Cliente CreateCliente(global::System.Int32 clienteID, global::System.String identificacion)
 {
     Cliente cliente = new Cliente();
     cliente.ClienteID = clienteID;
     cliente.Identificacion = identificacion;
     return cliente;
 }
Exemplo n.º 3
0
 public ActionResult Edit(Cliente cliente)
 {
     cliente.ClienteID = ClienteController.ID_Cliente;
     if (ModelState.IsValid)
     {
         //db.Entry(cliente).State = EntityState.Modified;
         db.Cliente.Attach(cliente);
         db.ObjectStateManager.ChangeObjectState(cliente, EntityState.Modified);
         db.SaveChanges();
         return PartialView("_Cliente_registrado", cliente);
     }
     return View(cliente);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Método desusado para agregar un nuevo objeto al EntitySet Cliente. Considere la posibilidad de usar el método .Add de la propiedad ObjectSet&lt;T&gt; asociada.
 /// </summary>
 public void AddToCliente(Cliente cliente)
 {
     base.AddObject("Cliente", cliente);
 }