예제 #1
0
        public async Task <IActionResult> Edit(int id,
                                               [Bind("ReceiptId,AppUserId,Id")] ReceiptParticipant receiptParticipant)
        {
            if (id != receiptParticipant.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _uow.ReceiptParticipants.Update(receiptParticipant);
                await _uow.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            var viewModel = new ReceiptParticipantViewModel
            {
                ReceiptParticipant = receiptParticipant,
                AppUsers           = new SelectList(await _uow.BaseRepository <AppUser>().AllAsync(), nameof(AppUser.Id),
                                                    nameof(AppUser.UserNickname)),
                Receipts = new SelectList(await _uow.Receipts.AllAsync(), nameof(Receipt.Id), nameof(Receipt.Id))
            };

            return(View(viewModel));
        }
예제 #2
0
        // GET: ReceiptParticipants/Create
        public async Task <IActionResult> Create()
        {
            var viewModel = new ReceiptParticipantViewModel
            {
                AppUsers = new SelectList(await _uow.BaseRepository <AppUser>().AllAsync(), nameof(AppUser.Id),
                                          nameof(AppUser.UserNickname)),
                Receipts = new SelectList(await _uow.Receipts.AllAsync(), nameof(Receipt.Id), nameof(Receipt.Id))
            };

            return(View(viewModel));
        }
예제 #3
0
        // GET: ReceiptParticipants/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var receiptParticipant = await _uow.ReceiptParticipants.FindAsync(id);

            if (receiptParticipant == null)
            {
                return(NotFound());
            }

            var viewModel = new ReceiptParticipantViewModel
            {
                ReceiptParticipant = receiptParticipant,
                AppUsers           = new SelectList(await _uow.BaseRepository <AppUser>().AllAsync(), nameof(AppUser.Id),
                                                    nameof(AppUser.UserNickname)),
                Receipts = new SelectList(await _uow.Receipts.AllAsync(), nameof(Receipt.Id), nameof(Receipt.Id))
            };

            return(View(viewModel));
        }