コード例 #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"));
        }