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)); }
public async Task <IActionResult> Post([FromBody] Laptop laptop) { var laptopadded = await _laptopService.AddLaptop(laptop); return(Ok(laptopadded)); }