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

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

            return(Ok(newCustomer));
        }
Esempio 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));
        }