Beispiel #1
0
        public IActionResult Add(AddressCreateInputModel addressCreateInputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            string userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            AddressServiceModel addressServiceModel = addressCreateInputModel.To <AddressServiceModel>();

            this.addressesService.AddAddress(addressServiceModel, userId);

            return(this.Redirect("/Orders/Create"));
        }
Beispiel #2
0
        public async Task <Address> CreateAsync(AddressCreateInputModel addressCreateInputModel)
        {
            if (addressCreateInputModel.City == null ||
                addressCreateInputModel.Street == null ||
                addressCreateInputModel.PostCode == null)
            {
                throw new ArgumentNullException("Some of the adress properties were null.");
            }

            var address = addressCreateInputModel.To <Address>();

            await this.addressRepository.AddAsync(address);

            await this.addressRepository.SaveChangesAsync();

            return(address);
        }
        public async Task <IActionResult> Create(AddressCreateInputModel addressCreateInputModel)
        {
            await this.addressService.CreateAsync(addressCreateInputModel.To <AddressServiceModel>(), this.User.Identity.Name);

            return(this.RedirectToAction("Create", "Orders"));
        }