Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        // ---------------------------------------- Guest only -----------------------------------

        public IActionResult Index_Guest()
        {
            HostEventsViewModel hostEventsViewModel = new HostEventsViewModel()
            {
                Gifts = _giftsRepository.GetAllGifts()
            };

            return(View(hostEventsViewModel));
        }
Ejemplo n.º 6
0
        public IActionResult Index(int EventId)
        {
            HostEventsViewModel hostEventsViewModel = new HostEventsViewModel()
            {
                Gifts = _giftsRepository.GetAllGiftsForEvent(EventId)
            };

            return(View(hostEventsViewModel));
        }
Ejemplo n.º 7
0
        public IActionResult Details(int EventId)
        {
            HostEventsViewModel hostEventsViewModel = new HostEventsViewModel
            {
                HostEvent = _hostEventsRepository.GetHostEvent(EventId),
                Guests    = _guestsRepository.GetAllGuestsForEvent(EventId),
                Gifts     = _giftsRepository.GetAllGiftsForEvent(EventId)
            };

            return(View(hostEventsViewModel));
        }
Ejemplo n.º 8
0
        public IActionResult Unassign(int EventId, int GiftId)
        {
            _giftsRepository.UnassignGift(GiftId);

            HostEventsViewModel hostEventsViewModel = new HostEventsViewModel()
            {
                Gifts = _giftsRepository.GetAllGiftsForEvent(EventId)
            };

            return(View("Index", hostEventsViewModel));
        }
Ejemplo n.º 9
0
 public IActionResult Edit(HostEventsViewModel hostEventsViewModel)
 {
     if (ModelState.IsValid)
     {
         _hostEventsRepository.UpdateHostEvent(hostEventsViewModel.HostEvent);
         return(RedirectToAction("Index", hostEventsViewModel));
     }
     else
     {
         return(View(hostEventsViewModel));
     }
 }
Ejemplo n.º 10
0
        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));
        }
Ejemplo n.º 11
0
        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");
                }
            });
        }
Ejemplo n.º 12
0
        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));
            }
        }
Ejemplo n.º 13
0
        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));
        }