Esempio n. 1
0
 public IActionResult AddLaptop(LaptopModel laptopModel)
 {
     try
     {
         laptopService.AddLaptop(laptopModel);
         laptopService.Save();
     }
     catch (Exception e)
     {
         return(BadRequest(laptopModel + e.Message));
     }
     return(Ok(laptopModel));
 }
        public async Task <IActionResult> CreateLaptop([FromBody] LaptopDTO data)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await laptopService.AddLaptop(data);

                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
            return(Conflict(ModelState));
        }
Esempio n. 3
0
        public async Task <IActionResult> Post([FromBody] Laptop laptop)
        {
            var laptopadded = await _laptopService.AddLaptop(laptop);

            return(Ok(laptopadded));
        }