Ejemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreateStoreRequest postStore)
        {
            if (ModelState.IsValid)
            {
                Store store = new Store
                {
                    Name    = _capitalize.ToCapitalize(postStore.Name),
                    Address = _capitalize.ToCapitalize(postStore.Address)
                };
                var created = await _storeServices.CreateStoreAsync(store);

                if (created != null)
                {
                    return(Ok(await _storeServices.GetStoresAsync()));
                }

                return(NotFound("Data Not Created"));
            }

            return(ValidationProblem());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] CreateProductRequest postproduct)
        {
            if (ModelState.IsValid)
            {
                Product product = new Product
                {
                    Name  = _capitalize.ToCapitalize(postproduct.Name),
                    Price = postproduct.Price
                };
                var created = await _productrServices.CreateProductAsync(product);

                if (created != null)
                {
                    return(Ok(await _productrServices.GetProductsAsync()));
                }

                return(NotFound("Data Not Created"));
            }

            return(ValidationProblem());
        }
        public async Task <IActionResult> Create([FromBody] CreateCustomerRequest postCustomer)
        {
            if (ModelState.IsValid)
            {
                Customer customer = new Customer
                {
                    Name    = _capitalize.ToCapitalize(postCustomer.Name),
                    Address = _capitalize.ToCapitalize(postCustomer.Address)
                };
                var created = await _customerServices.CreateCustomerAsync(customer);


                if (created != null)
                {
                    return(Ok(await _customerServices.GetCustomersAsync()));
                }

                return(NotFound("Data Not Created"));
            }

            return(ValidationProblem());
        }