예제 #1
0
        public async Task <IActionResult> EditPost(TUpdateVm model)
        {
            if (ModelState.IsValid)
            {
                var result = await _interactor.GetAsync(model.Id);

                if (!result.Success)
                {
                    return(NotFound());
                }

                result = await _interactor.UpdateAsync(MapFromUpdateViewModel(result.Entity, model));

                if (result.Success)
                {
                    return(RedirectToAction("Index"));
                }

                ModelState.AddOperationResultErrors(result.ErrorMessages);
            }

            model = await FillViewModel(model);

            return(View("Edit", model));
        }
예제 #2
0
        public async Task <IActionResult> VerifyPhone([FromBody] CodeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _mediator.Send(new VerificationCodeConfirmationCommand(model.Mobile, model.Code));

            if (!result.Succeeded)
            {
                ModelState.AddOperationResultErrors(result);
                return(BadRequest(ModelState));
            }

            return(Ok());
        }
예제 #3
0
        public async Task <IActionResult> LendPost(LendingViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await _interactor.Lend(model.BookId, model.LenderId, model.From, model.To);

                if (result.Success)
                {
                    return(RedirectToAction("Index"));
                }

                ModelState.AddOperationResultErrors(result.ErrorMessages);
            }

            model.Lenders = await GetLendersDropdown();

            return(View("Lend", model));
        }
예제 #4
0
        public async Task <IActionResult> CreatePost(TCreateVm model)
        {
            if (ModelState.IsValid)
            {
                var result = await _interactor.CreateAsync(MapFromCreateViewModel(model));

                if (result.Success)
                {
                    return(RedirectToAction("Index"));
                }

                ModelState.AddOperationResultErrors(result.ErrorMessages);
            }

            model = await FillViewModel(model);

            return(View("Create", model));
        }