Exemple #1
0
        public async Task <IActionResult> CreateRetailstore([FromForm] RetailstoreToCreate retailstore)
        {
            // Missing parameters
            // More info in response
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            // map the customer model
            // USES: automapper instead of handtyped
            var newRetailstore = _mapper.Map <Retailstore>(retailstore);

            _context.Add(newRetailstore);

            await _context.SaveChangesAsync();

            return(Ok(newRetailstore));
        }
        public async Task <IActionResult> CreateCustomer([FromBody] CustomerToCreate customer)
        {
            // Missing parameters
            // More info in response
            if (!ModelState.IsValid)
            {
                await TimeStampError();

                return(BadRequest());
            }

            // map the customer model
            // USES: automapper instead of handtyped
            var newCustomer = _mapper.Map <Customer>(customer);

            _context.Add(newCustomer);

            await _context.SaveChangesAsync();

            await TimeStampTransaction();

            return(Ok(newCustomer));
        }