コード例 #1
0
        public async Task <ActionResult> CreateAutomobile(ApiAutomobileForCreate apiCar)
        {
            var car    = _mapper.Map <AutomobileInfo>(apiCar);
            var newCar = await _automobileManager.CreateAsync(car);

            if (newCar == null || !_automobileManager.ProcessResult.Success)
            {
                throw new Exception(_automobileManager.ProcessResult.GetWholeMessage());
            }

            return(Ok(newCar));
        }
コード例 #2
0
        public async Task <ActionResult> Post(ApiDiscountForCreate apiDiscount)
        {
            var discount    = _mapper.Map <GasDiscount>(apiDiscount);
            var newDiscount = await _discountManager.CreateAsync(discount);

            if (newDiscount == null)
            {
                return(BadRequest("Cannot create discount"));
            }

            return(Ok(newDiscount));
        }