Ejemplo n.º 1
0
        public async Task <IActionResult> AddAsync([FromRoute] int customerNumber, [FromBody] CustomerAddress newAddress)
        {
            _customerContext.CustomerAddress.Add(newAddress);
            await _customerContext.SaveChangesAsync();

            return(Ok(newAddress));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddAsync([FromBody] RetailCustomer newCustomer)
        {
            _customerContext.RetailCustomer.Add(newCustomer);
            await _customerContext.SaveChangesAsync();

            return(Ok(newCustomer));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddAsync([FromBody] CorporateCustomer newCustomer)
        {
            string validationResult = newCustomer.ValidateAndPrepeareForInsert();

            if (!string.IsNullOrEmpty(validationResult))
            {
                Error a = new Error();

                a.Title   = "Invalid fields";
                a.Message = validationResult;

                return(BadRequest(a));
            }

            _customerContext.CorporateCustomer.Add(newCustomer);
            await _customerContext.SaveChangesAsync();

            return(Ok(newCustomer));
        }