예제 #1
0
        public async Task ValidModel_Create_ShouldSucceed()
        {
            var tax      = MockModels.GetTaxRequest();
            var testGuid = Guid.NewGuid();

            _taxesRepository
            .Setup(e => e.Add(It.IsAny <TaxEntity>()))
            .Returns(Task.FromResult(testGuid));

            Assert.AreEqual(testGuid, await _taxesService.Create(tax));
        }
예제 #2
0
        public ActionResult Create([Bind("ixTax,sTax,ixCountry,ixCountrySubDivision,nRate")] TaxesPost taxes)
        {
            if (ModelState.IsValid)
            {
                taxes.UserName = User.Identity.Name;
                _taxesService.Create(taxes);
                return(RedirectToAction("Index"));
            }
            ViewBag.ixCountry            = new SelectList(_taxesService.selectCountries().Select(x => new { x.ixCountry, x.sCountry }), "ixCountry", "sCountry");
            ViewBag.ixCountrySubDivision = new SelectList(_taxesService.selectCountrySubDivisions().Select(x => new { x.ixCountrySubDivision, x.sCountrySubDivision }), "ixCountrySubDivision", "sCountrySubDivision");

            return(View(taxes));
        }
예제 #3
0
 public async Task <IActionResult> Create([FromBody] TaxRequest taxRequest)
 {
     return(new OkObjectResult(await _taxesService.Create(taxRequest)));
 }