public static AbstractEntities.NewCurrency ToAbstract(this NewCurrency web) { if (web == null) { return(null); } return(new AbstractEntities.NewCurrency(web.Code)); }
public IActionResult Create([FromBody] NewCurrency newCurrency) { if (newCurrency == null) { throw new InvalidRequestArgumentException("The currency cannot be null or empty."); } if (string.IsNullOrWhiteSpace(newCurrency.Code)) { throw new InvalidRequestArgumentException("Currency code cannot be null or empty."); } var createdCurrency = dataLayer.CreateCurrency(newCurrency.ToAbstract()); return(CreatedAtAction("Get", new { id = createdCurrency.Id }, createdCurrency.ToWeb())); }
public static Currency CreateCurrency(this CurrenciesController controller, NewCurrency newCurrency) { var actionResult = (CreatedAtActionResult)controller.Create(newCurrency); return((Currency)actionResult.Value); }