Пример #1
0
        public ClientesDTO Post(PostCliente request)
        {
            var cliente = _unitOfWork.Clientes.Find(request.Cliente.ClienteId);

            if (cliente != null)
            {
                return(new ClientesDTO
                {
                    ValidationErrorMessage = "ClienteId YA existe!"
                });
            }

            cliente = new Clientes(request.Cliente.Nombre);

            var mensajeValidacion = cliente.GetValidationErrors();

            if (mensajeValidacion.Any())
            {
                return(new ClientesDTO
                {
                    ValidationErrorMessage = mensajeValidacion.FirstOrDefault()
                });
            }

            _unitOfWork.Clientes.Add(cliente);
            _unitOfWork.SaveChanges();

            return(new ClientesDTO());
        }
Пример #2
0
 public VistaClienteSeleccionado(PostCliente postCliente)
 {
     pc = postCliente;
     InitializeComponent();
     nombreCliente.Text   = pc.Nombre;
     telefonoCliente.Text = pc.Telefono;
     idCliente.Text       = pc.Id.ToString();
     addButon.IsVisible   = false;
 }
Пример #3
0
        public async Task <ActionResult <ClienteOutput> > PostCliente(PostCliente cliente)
        {
            var clienteNovo = cliente.MapTo <Cliente>();
            await _clientes.Create(clienteNovo);

            await _clientes.Commit();

            return(CreatedAtAction("GetCliente", new { id = clienteNovo.Id }, clienteNovo.MapTo <ClienteOutput>()));
        }
Пример #4
0
        private async void OnAdd(object sender, EventArgs e)
        {
            bool error = false;

            Mensajerror.Text = null;
            if (nombreCliente.Text == null || telefonoCliente.Text == null || passCliente == null)
            {
                error             = true;
                Mensajerror.Text += "Has dejado campos vacios";
            }
            else
            {
                if (!Regex.IsMatch(nombreCliente.Text, core.expresionRegularNombre))
                {
                    error            = true;
                    Mensajerror.Text = "El nombre no puede incluir numeros ni caracteres especiales " + Environment.NewLine;
                }
                if (!Regex.IsMatch(telefonoCliente.Text, core.expresionRegularTelefono))
                {
                    error             = true;
                    Mensajerror.Text += "El Telefono no es correcto";
                }
            }
            if (error)
            {
            }
            else
            {
                pc          = new PostCliente();
                pc.Nombre   = nombreCliente.Text;
                pc.password = core.Hash(passCliente.Text);
                pc.Telefono = telefonoCliente.Text;
                using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
                {
                    conn.CreateTable <PostCliente>();
                    int rowsAdded = conn.Insert(pc);
                }
                await Navigation.PopAsync();

                /*
                 * string content = null;
                 * content = JsonConvert.SerializeObject(new { telefono_contacto = telefonoCliente.Text, nombre = nombreCliente.Text, password = core.Hash(passCliente.Text) }); //Serializes or convert the created Post into a JSON String
                 * var eksudi = await connection.Response.PostAsync(connection.Url, new StringContent(content, Encoding.UTF8, "application/json")); //Send a POST request to the specified Uri as an asynchronous operation and with correct character encoding (utf9) and contenct type (application/json).
                 *
                 *
                 * if (eksudi.IsSuccessStatusCode) { Toast.MakeText(Android.App.Application.Context, "Se ha añadido correctamente al cliente : " + nombreCliente.Text, ToastLength.Long).Show(); }
                 * else { Toast.MakeText(Android.App.Application.Context, "Ha ocurrido un error", ToastLength.Long).Show(); }
                 */
            }
        }
Пример #5
0
 public object Post(PostCliente request)
 {
     return(_clientesAppServices.Post(request));
 }