コード例 #1
0
        public async Task <IActionResult> Add(AddBranchViewModel branchModel)
        {
            string fullAddress = branchModel.Address + " " + branchModel.Town;

            //TODO: make branch add friendly error page
            if (!ModelState.IsValid)
            {
                this.TempData.AddFailureMessage(string.Format(FailureAddItemMessage, fullAddress));
                return(this.RedirectToAction(nameof(Index)));
                //return this.BadRequest();
            }

            await branchesService.AddBranchAsync(branchModel.Town, branchModel.Address);

            this.TempData.AddSuccessMessage(string.Format(SuccessAddItemMessage, fullAddress));
            return(this.RedirectToAction(nameof(Index)));
        }