Esempio n. 1
0
        public async Task <IActionResult> Postcustomerprofile([FromBody] customerprofileTemp customerprofile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            customerprofile profile = new customerprofile();

            profile.Name        = customerprofile.Name;
            profile.Address     = customerprofile.Address;
            profile.DateOfBirth = customerprofile.DateOfBirth;
            profile.PhoneNumber = customerprofile.PhoneNumber;
            _context.customerprofile.Add(profile);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (customerprofileExists(customerprofile.Name))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("Getcustomerprofile", new { id = customerprofile.Name }, customerprofile));
        }