Ejemplo n.º 1
0
        // GET: User
        public ActionResult Details(string username)
        {
            var user = eventUoW.Users.GetUserByUsername(username);

            if (User.Identity.IsAuthenticated)
            {
                eventUoW.Events.GetAllCreatedEvents(user);
            }
            else
            {
                eventUoW.Events.GetAllPublicEventsOfUser(user);
            }

            if (user != null)
            {
                // Mark all invites as seen if we are going to view our own page (since we'll be seeing them soon).
                if (User.Identity.GetUserId() == user.Id)
                {
                    eventUoW.Invites.MarkAllInvitesAsSeen(user);
                    eventUoW.Save();
                }

                // Return the page.
                var vm = new UserDetailsViewModel();
                vm.User    = user;
                vm.Invites = eventUoW.Invites.GetAllInvitedEvents(user);
                return(View(new HellViewModel {
                    UserDetailsViewModel = vm
                }));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Generate(int eventId)
        {
            Event e = eventUoW.Events.GetEventByID(eventId);

            if (e == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            if (User.Identity.GetUserId() != e.OwnerId)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            Guid       guid = Guid.NewGuid();
            InviteLink link = new InviteLink {
                EventId = eventId, LinkGUID = guid.ToString(), OneTimeUse = true, ModificationState = ModificationState.Added
            };

            eventUoW.InviteLinks.Attach(link);
            eventUoW.Save();

            UrlHelper urlHelper = new UrlHelper(HttpContext.Request.RequestContext);
            string    url       = urlHelper.Action("Details", "Event", new { id = eventId, guid = guid.ToString() }, urlHelper.RequestContext.HttpContext.Request.Url.Scheme);

            return(Json(new { url = url }));
        }
Ejemplo n.º 3
0
        public ActionResult Create(HellViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Create a new event.
                Event e = new Event();
                e.Brief             = model.CreateViewModel.Brief;
                e.Detailed          = model.CreateViewModel.Detailed;
                e.Visibility        = model.CreateViewModel.Visibility;
                e.Address           = model.CreateViewModel.Address;
                e.Latitude          = model.CreateViewModel.Latitude;
                e.Longitude         = model.CreateViewModel.Longitude;
                e.StartTime         = model.CreateViewModel.StartTime;
                e.ModificationState = ModificationState.Added;
                e.OwnerId           = User.Identity.GetUserId();
                eventUoW.Events.Attach(e);

                // Create a share link for this event.
                InviteLink link = new InviteLink();
                link.Event             = e;
                link.LinkGUID          = Guid.NewGuid().ToString();
                link.OneTimeUse        = false;
                link.ModificationState = ModificationState.Added;
                eventUoW.InviteLinks.Attach(link);

                // Save the changes.
                eventUoW.Save();

                return(RedirectToAction("Details", "Event", new { id = e.Id }));
            }

            return(View());
        }
Ejemplo n.º 4
0
 public IActionResult EditEvent(Event ev)
 {
     if (ModelState.IsValid)
     {
         int    Selectedmonth = ev.start.Month;
         int    Selectedyear  = ev.start.Year;
         string Message;
         if (ev.EventId == 0)
         {
             // context.Events.Add(ev);
             _uow.Events.Insert(ev);
             Message = $"Event added on {DateTime.UtcNow.ToLongTimeString()}";
         }
         else
         {
             // context.Events.Update(ev);
             _uow.Events.Update(ev);
             Message = $"Event updated on {DateTime.UtcNow.ToLongTimeString()}";
         }
         // context.SaveChanges();
         _uow.Save();
         _logger.LogInformation(Message);
         return(RedirectToAction("timeIndex", new { month = Selectedmonth, year = Selectedyear }));
     }
     else
     {
         string Message = $"Error Editing information occured at {DateTime.UtcNow.ToLongTimeString()}";
         _logger.LogInformation(Message);
         return(View(ev));
     }
 }
Ejemplo n.º 5
0
        public async Task <ActionResult> ConnectNewAccount(HellViewModel model, string returnUrl)
        {
            if (HasPassword())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            if (ModelState.IsValid)
            {
                var socialUser = eventUoW.Users.GetUserById(User.Identity.GetUserId());
                IList <UserLoginInfo> loginInfo = eventUoW.Users.UserManager.GetLogins(socialUser.Id);

                var newUser = new AppUser()
                {
                    UserName = model.ConnectNewAccountViewModel.UserName
                };
                var result = await eventUoW.Users.UserManager.CreateAsync(newUser, model.ConnectNewAccountViewModel.Password);

                eventUoW.Users.RemoveAccount(socialUser);
                eventUoW.Save();
                eventUoW.Users.UserManager.AddLogin(newUser.Id, loginInfo[0]);
                if (result.Succeeded)
                {
                    await SignInAsync(newUser, isPersistent : false);

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    AddErrors(result);
                }
            }

            ViewBag.ReturnUrl = returnUrl;
            return(View(model));
        }