public ActionResult <SampleContinent> AddContinent([FromBody] Sample_Models.SampleContinent con) { try { Continent temp = new Continent(con.Name); if (ContinentManager.IfExist(temp)) { ContinentManager.Add(temp); logger.LogInformation("ContinentController : Add => " + DateTime.Now); return(CreatedAtAction(nameof(Get), new { id = temp.ID }, temp)); } else { return(BadRequest("Continent already exist")); } } catch (Exception e) { return(BadRequest("Something went wrong : " + e)); } }
public ActionResult <SampleContinent> Put(int id, [FromBody] SampleContinent con) { try { var temp = ContinentManager.Get(id); if (ContinentManager.IfExist(new Continent(con.Name))) { logger.LogInformation("ContinentController : Put => " + DateTime.Now); temp.SetName(con.Name); ContinentManager.Update(temp); return(CreatedAtAction(nameof(Get), new { id = temp.ID }, temp)); } else { return(BadRequest("Continent already Exists")); } } catch (Exception e) { return(NotFound("Continent doesn't exist")); } }