Esempio n. 1
0
 public IActionResult AddAdult([FromBody] Adult adult)
 {
     try
     {
         AdultService.AddAdultAsync(adult);
         return(Ok());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
        public async Task <ActionResult> AddAdult([FromBody] Adult adult)
        {
            try
            {
                await adultService.AddAdultAsync(adult);

                return(Ok());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }
        }
Esempio n. 3
0
        public async Task <ActionResult <Adult> > AddAdultAsync([FromBody] Adult adult)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try{
                Adult adult1 = await adultService.AddAdultAsync(adult);

                return(Ok(adult1));
            }catch (Exception e) {
                Console.WriteLine(e.Message);
                return(StatusCode(409, e.Message));
            }
        }
        public async Task <ActionResult <Adult> > AddAdult([FromBody] Adult adult)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try {
                Adult added = await adultsService.AddAdultAsync(adult);

                return(Created($"/{added.Id}", added));
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(StatusCode(500, e.Message));
            }
        }
        public async Task <ActionResult <Adult> > AddAdult([FromBody] Adult adult, [FromRoute] string Address)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                Adult toAdd = await adultService.AddAdultAsync(adult, Address);

                return(Created($"/{toAdd}", toAdd));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Esempio n. 6
0
    public IActionResult AddAdult([FromBody] Adult adult)
    {
        Console.WriteLine("y u're wrong");
        try
        {
            Console.WriteLine(adult.id);
            AdultService.AddAdultAsync(adult);

            // Adult adult1 = new Adult()
            // {
            //     id = 11,
            //     age = 50,
            //     eyeColor = "Blue",
            //     hairColor = "Black",
            //     firstName = "theSixth",
            //     lastName = "Magana",
            //     height = 182,
            //     jobTitle = "abaaba6",
            //     sex = "M",
            //     weight = 123,
            // };
            // Console.WriteLine("now adding");
            // AdultService.AddAdultAsync(adult1);
            // Console.WriteLine("add succedds!");



            // Console.WriteLine("httpPuting");
            // Console.WriteLine(adult);
            // AdultService.AddAdultAsync(adult);
            // Console.WriteLine("httpPut ok!");
            return(Ok());
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }
    }