Esempio n. 1
0
        public IActionResult EditReservation(ReservationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.AccountList   = _accountQueryService.GetAllAccountData().AccountDataList;
                model.EquipmentList = _equipmentQueryService.GetAllEquipmentData().EquipmentDataList;
                ModelState.AddModelError(string.Empty, "入力内容が不正です。");
                return(View(model));
            }

            var request = new ChangeReservationInfoRequest()
            {
                ReservationId = model.Id,
                AccountId     = model.SelectedAccountId,
                EquipmentId   = model.SelectedEquipmentId,
                StartDateTime = model.GetStartDateTime().Value,
                EndDateTime   = model.GetEndDateTime().Value,
                PurposeOfUse  = model.PurposeOfUse
            };

            try
            {
                _reservationAppService.ChangeReservationInfo(request);
            }
            catch (ReservationDupulicationException)
            {
                model.AccountList   = _accountQueryService.GetAllAccountData().AccountDataList;
                model.EquipmentList = _equipmentQueryService.GetAllEquipmentData().EquipmentDataList;
                ModelState.AddModelError(string.Empty, "予約が重複しています。");
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }