public Customer AddNewCustomer(AddCustomerDTO newCustomer)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"INSERT INTO[dbo].[Customer]
                                                    ([DateCreated]
                                                    ,[FirebaseKey])
	                                        output inserted.*
                                                VALUES
                                                    (@dateCreated
                                                    , @firebaseKey)";
                return(db.QueryFirst <Customer>(sql, newCustomer));
            }
        }
        public async Task InsertCustomer(AddCustomerDTO addCustomerDTO)
        {
            var customer = new Customer
            {
                Id        = addCustomerDTO.Id,
                Username  = addCustomerDTO.Username,
                Password  = addCustomerDTO.Password,
                Email     = addCustomerDTO.Email,
                FirstName = addCustomerDTO.FirstName,
                LastName  = addCustomerDTO.LastName
            };

            this.dbContext.Customers.Add(customer);
            await dbContext.SaveChangesAsync();
        }
        public IActionResult Post([FromBody] AddCustomerDTO addCustomerDTO)
        {
            if (addCustomerDTO == null)
            {
                return(BadRequest());
            }

            var response = application.Insert(addCustomerDTO);

            if (response.IsSuccess)
            {
                return(Ok(response));
            }

            return(BadRequest(response.Message));
        }
        public async Task <IActionResult> PostAsync([FromBody] AddCustomerDTO addCustomerDTO)
        {
            if (addCustomerDTO == null)
            {
                return(BadRequest());
            }

            var response = await application.InsertAsync(addCustomerDTO);

            if (response.IsSuccess)
            {
                return(Ok(response));
            }

            return(BadRequest(response.Message));
        }
        public Response <bool> Insert(AddCustomerDTO addCustomerDTO)
        {
            var response = new Response <bool>();

            try
            {
                var customer = mapper.Map <Customer>(addCustomerDTO);
                response.Data = domain.Insert(customer);

                if (response.Data)
                {
                    response.IsSuccess = true;
                    response.Message   = "Registro exitoso";
                }
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }

            return(response);
        }
示例#6
0
        private async void guardarButton_Click(object sender, EventArgs e)
        {
            var addCustomerDTO = new AddCustomerDTO()
            {
                Cliente         = nombreClienteText.Text,
                DNI             = documentoIdentidadText.Text,
                FechaNacimiento = fecchaNacimientoDateTime.Value,
            };

            var json    = JsonConvert.SerializeObject(addCustomerDTO);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage httpResponse = await httpClient.PostAsync($"{apiURL}/customers/postAsync", content);

            Response <bool> response = await httpResponse.Content.ReadAsAsync <Response <bool> >();

            if (response.IsSuccess)
            {
                MessageBox.Show(response.Message, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            MessageBox.Show(response.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
示例#7
0
        public async Task <IActionResult> Post(AddCustomerDTO addCustomerDTO)
        {
            await customerService.InsertCustomer(addCustomerDTO);

            return(Ok(addCustomerDTO));
        }