public IActionResult Create(string HostId, HostEventsViewModel hostEventsViewModel) { if (ModelState.IsValid) { PasswordHasher passwordHasher = new PasswordHasher(); //var password = passwordHasher.HashToString(hostEventsViewModel.HostEvent.EventPassword); HostEvent hostEvent = new HostEvent() { EventTitle = hostEventsViewModel.HostEvent.EventTitle, EventDescription = hostEventsViewModel.HostEvent.EventDescription, EventDate = hostEventsViewModel.HostEvent.EventDate, //EventPassword = password, EventPassword = passwordHasher.HashToString(hostEventsViewModel.HostEvent.EventPassword), Location = hostEventsViewModel.HostEvent.Location, HostId = _userManager.GetUserId(User), MaxReservable = hostEventsViewModel.HostEvent.MaxReservable, Status = hostEventsViewModel.HostEvent.Status, }; if (hostEventsViewModel.HostEvent.Status == null) { hostEvent.Status = "TBC"; } ; _hostEventsRepository.CreateHostEvent(hostEvent); return(RedirectToAction("Index")); } return(View("Create")); }
public IActionResult MarkAsBought(int EventId, int GiftId) { Gift gift = _giftsRepository.GetGiftById(GiftId); var userId = _userManager.GetUserId(User); HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Gifts = _giftsRepository.GetAllGiftsForEvent(EventId) }; if (gift.Status == "Reserved" && gift.GuestId == userId) { _giftsRepository.MarkAsBought(gift.GiftId, userId); } else if (_giftsRepository.CheckGiftLimit(_userManager.GetUserId(User), EventId)) { _giftsRepository.MarkAsBought(GiftId, _userManager.GetUserId(User)); return(View("Index", hostEventsViewModel)); } else { ModelState.AddModelError("", "You have already reserved the maximum number of gifts permitted"); } return(View("Index", hostEventsViewModel)); }
public async Task <IActionResult> Index() { string[] roles = new string[] { "Host", "Guest" }; foreach (var role in roles) { if (await _roleManager.FindByNameAsync(role) == null) { await _roleManager.CreateAsync(new IdentityRole(role)); } } //await _userManager.AddToRoleAsync(await _userManager.GetUserAsync(User), "Guest"); string UserId = _userManager.GetUserId(User); HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { EventsHosting = _hostEventsRepository.GetAllEventsHosting(UserId).ToList(), EventsAttending = _hostEventsRepository.GetAllEventsAttending(UserId).ToList(), EventInvitations = _hostEventsRepository.GetEventInvitations(_userManager.GetUserName(User)).ToList() }; return(View(hostEventsViewModel)); }
public IActionResult Edit(int EventId) { HostEvent hostEvent = _hostEventsRepository.GetHostEvent(EventId); List <SelectListItem> Status = new List <SelectListItem> { new SelectListItem() { Text = "TBA", Value = "TBA" }, new SelectListItem() { Text = "Upcoming", Value = "Upcoming" }, new SelectListItem() { Text = "Postponed", Value = "Postponed" }, new SelectListItem() { Text = "Cancelled", Value = "Cancelled" } }; HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { HostEvent = hostEvent, EventId = hostEvent.EventId, Status = Status }; return(View(hostEventsViewModel)); }
// ---------------------------------------- Guest only ----------------------------------- public IActionResult Index_Guest() { HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Gifts = _giftsRepository.GetAllGifts() }; return(View(hostEventsViewModel)); }
public IActionResult Index(int EventId) { HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Gifts = _giftsRepository.GetAllGiftsForEvent(EventId) }; return(View(hostEventsViewModel)); }
public IActionResult Details(int EventId) { HostEventsViewModel hostEventsViewModel = new HostEventsViewModel { HostEvent = _hostEventsRepository.GetHostEvent(EventId), Guests = _guestsRepository.GetAllGuestsForEvent(EventId), Gifts = _giftsRepository.GetAllGiftsForEvent(EventId) }; return(View(hostEventsViewModel)); }
public IActionResult Unassign(int EventId, int GiftId) { _giftsRepository.UnassignGift(GiftId); HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Gifts = _giftsRepository.GetAllGiftsForEvent(EventId) }; return(View("Index", hostEventsViewModel)); }
public IActionResult Edit(HostEventsViewModel hostEventsViewModel) { if (ModelState.IsValid) { _hostEventsRepository.UpdateHostEvent(hostEventsViewModel.HostEvent); return(RedirectToAction("Index", hostEventsViewModel)); } else { return(View(hostEventsViewModel)); } }
public IActionResult RequestOwnership(int EventId, int GiftId) { HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Gifts = _giftsRepository.GetAllGiftsForEvent(EventId) }; _giftsRepository.SendOwnershipRequest(_userManager.GetUserId(User), GiftId); ModelState.AddModelError("", "Your request has been sent"); return(View("Index", hostEventsViewModel)); }
public YourEventsView() { InitializeComponent(); this.vm = new HostEventsViewModel(); this.BindingContext = vm; MessagingCenter.Subscribe <HostEventsViewModel>(this, "cancel_message", async(sender) => { bool cancel = await DisplayAlert("Cancel Event", "Are you sure you want to cancel this event?", "Yes", "Cancel"); if (cancel) { MessagingCenter.Send <YourEventsView>(this, "cancel"); } }); }
public IActionResult ReserveGift(int EventId, int GiftId) { HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Gifts = _giftsRepository.GetAllGiftsForEvent(EventId) }; if (_giftsRepository.CheckGiftLimit(_userManager.GetUserId(User), EventId)) { _giftsRepository.ReserveGift(GiftId, _userManager.GetUserId(User)); return(View("Index", hostEventsViewModel)); } else { ModelState.AddModelError("", "You have already claimed the maximum number of gifts permitted"); return(View("Index", hostEventsViewModel)); } }
public IActionResult Create() { List <SelectListItem> Status = new List <SelectListItem> { new SelectListItem() { Text = "TBA", Value = "TBA" }, new SelectListItem() { Text = "Upcoming", Value = "Upcoming" } }; HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { Status = Status }; return(View(hostEventsViewModel)); }