コード例 #1
0
        public async Task <IActionResult> Update(int id, RaffleItemUpdateModel model)
        {
            if (ModelState.IsValid)
            {
                var command = new UpdateRaffleItemCommand
                {
                    Id              = id,
                    ItemNumber      = model.ItemNumber,
                    Title           = model.Title,
                    Description     = model.Description ?? string.Empty,
                    Category        = model.Category ?? string.Empty,
                    Sponsor         = model.Sponsor ?? string.Empty,
                    Cost            = model.Cost,
                    ItemValue       = model.ItemValue ?? string.Empty,
                    IsAvailable     = model.IsAvailable,
                    ForOver21       = model.ForOver21,
                    LocalPickupOnly = model.LocalPickupOnly,
                    NumberOfDraws   = model.NumberOfDraws,
                    Order           = model.Order,
                    WinningTickets  = model.WinningTickets ?? string.Empty
                };
                await mediator.Publish(command);

                return(RedirectToAction("Index"));
            }

            return(View("RaffleItemUpdate"));
        }
コード例 #2
0
        public IActionResult Update(int id)
        {
            var raffleItem = raffleItemRepository.GetById(id);
            var model      = new RaffleItemUpdateModel
            {
                Id              = id,
                ItemNumber      = raffleItem.ItemNumber,
                Title           = raffleItem.Title,
                Description     = raffleItem.Description,
                Category        = raffleItem.Category,
                Sponsor         = raffleItem.Sponsor,
                ItemValue       = raffleItem.ItemValue,
                Cost            = raffleItem.Cost,
                IsAvailable     = raffleItem.IsAvailable,
                ForOver21       = raffleItem.ForOver21,
                LocalPickupOnly = raffleItem.LocalPickupOnly,
                NumberOfDraws   = raffleItem.NumberOfDraws,
                Order           = raffleItem.Order,
                WinningTickets  = raffleItem.WinningTickets
            };

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