public IActionResult GiftList(int id, Hamper hamper) { IEnumerable <Gift> gifts = _giftRepo.GetAll(); IEnumerable <HamperGift> hamperGifts = _hamperGiftRepo.Query(hg => hg.HamperId == hamper.HamperId); Hamper _hamper = new Hamper(); if (hamper.HamperId == 0) { _hamper = _hamperRepo.GetSingle(h => h.HamperId == id); } else { _hamper = hamper; } if (gifts.Count() == 0) { return(RedirectToAction("Create", "Gift")); } GiftListViewModel vm = new GiftListViewModel(); if (hamperGifts.Count() == 0) { vm.HamperGifts = new List <HamperGift>(); } vm.Gifts = gifts; vm.HamperGifts = hamperGifts; vm.Hamper = _hamper; return(View(vm)); }
// GET: Gift // GET: Gift/{page} public ActionResult Index(int page) { /* * For Mockup */ var logic = new GiftLogic(); var gifts = logic.SelectGift(); var listViewModel = new GiftListViewModel { SearchCondition = new GiftSearchConditionViewModel { CountrySelectList = new SelectList( new Dictionary <int, string> { { 0, "選択してください" }, { 1, "日本" }, { 2, "フランス" } }, "Key", "Value", 0) }, Gifts = PagedListHelper.NewInstance(gifts, page) }; return(View(listViewModel)); }
public async Task <ActionResult> NotApproved() { var model = new GiftListViewModel { Gifts = await _unitofWork.Gifts.GetAll(g => g.Status == Core.Enums.GiftStatus.NotApproved, u => u.User), }; return(View("incheckup_table", model)); }
public IActionResult CreateHamperGift(GiftListViewModel vm, int giftId, int hampId) { Gift gift = _giftRepo.GetSingle(g => g.GiftId == giftId); Hamper hamper = _hamperRepo.GetSingle(h => h.HamperId == hampId); HamperGift hamperGift = new HamperGift() { GiftId = giftId, GiftName = gift.Name, HamperId = hampId }; //HamperName = hamper.Name _hamperGiftRepo.Create(hamperGift); return(RedirectToAction("GiftList", "Hamper", hamper)); }
public async Task <ActionResult> List(GiftStatus status = GiftStatus.Approved) { User current_user = Session["user"] as User; var gifts = await _unitofWork.Gifts.GetAll( g => g.User.Id == current_user.Id && g.Status == status); gifts = gifts.OrderBy(g => g.CreatedAt).ToList(); var model = new GiftListViewModel { Gifts = gifts, GiftStatus = status, GiftStatuses = (IList <GiftStatus>)Enum.GetValues(typeof(GiftStatus)) }; return(View(model)); }