Пример #1
0
        public static AbstractEntities.NewCurrency ToAbstract(this NewCurrency web)
        {
            if (web == null)
            {
                return(null);
            }

            return(new AbstractEntities.NewCurrency(web.Code));
        }
Пример #2
0
        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()));
        }
Пример #3
0
        public static Currency CreateCurrency(this CurrenciesController controller, NewCurrency newCurrency)
        {
            var actionResult = (CreatedAtActionResult)controller.Create(newCurrency);

            return((Currency)actionResult.Value);
        }