Beispiel #1
0
        public ActionResult GetNotifications()
        {
            //var list = new List<CH_EventRegistrationFromOrganizer>();
            try
            {
                var notificationRegisterTime = Session["LastUpdated"] != null?Convert.ToDateTime(Session["LastUpdated"]) : DateTime.Now;

                NotificationComponent NC = new NotificationComponent();
                Tuple <List <EventRegistrationfromOrganizerModel>, List <LikesModel>, List <ShareModel>, List <SubscribersModel>, List <CommentModel>, List <SubCommentModel> > list = NC.GetData(notificationRegisterTime);



                Session["LastUpdate"] = DateTime.Now;
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(View("~/Views/Errorpage/Errorpage.cshtml"));
            }
        }
Beispiel #2
0
        public async Task <ActionResult> Login(LoginRegistration model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await UserManager1.FindByEmailAsync(model.login.Email);

            Session["UserId"] = user.Id;
            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            if (user != null)
            {
                if (user.EmailConfirmed == true)
                {
                    var result = await SignInManager.PasswordSignInAsync(user.UserName, model.login.Password, model.login.RememberMe, shouldLockout : false);



                    switch (result)
                    {
                    case SignInStatus.Success:



                        if (user.UserActive == false || user.UserActive == null)
                        {
                            user.UserActive = true;
                            var result2 = UserManager1.Update(user);
                        }

                        Session["usertype"] = user.Usertype;
                        var usertype = user.Usertype;
                        Session["EmailId"] = model.login.Email;

                        if (usertype == 1)
                        {
                            try
                            {
                                ApplicationMandatoryService AmService = new ApplicationMandatoryService();
                                NotificationComponent       NC        = new NotificationComponent();
                                AmService.SaveUserSession();

                                var data = await AmService.GetLastLogindb(Session["UserId"] as string);

                                var currentTime = data.CreatedDateandTime;
                                Session["LastUpdated"] = currentTime;
                                NC.RegisterNotification(currentTime);
                                return(RedirectToAction("Home", "OrganizerBasicDetails"));
                            }
                            catch (Exception ex)
                            {
                                return(View("~/Views/Errorpage/Errorpage.cshtml"));
                            }
                        }
                        else
                        {
                            try
                            {
                                ViewBag.UserType = "Participants";
                                ApplicationMandatoryService AmService = new ApplicationMandatoryService();

                                AmService.SaveUserSession();
                                NotificationComponent NC = new NotificationComponent();
                                AmService.SaveUserSession();

                                var data = await AmService.GetLastLogindb(User.Identity.GetUserId());

                                var currentTime = data.CreatedDateandTime;
                                Session["LastUpdated"] = currentTime;
                                NC.RegisterNotification(currentTime);
                                return(RedirectToAction("ParticipantHome", "Participants"));
                            }
                            catch (Exception ex)
                            {
                                return(View("~/Views/Errorpage/Errorpage.cshtml"));
                            }
                        }

                    case SignInStatus.LockedOut:
                        return(View("Lockout"));

                    case SignInStatus.RequiresVerification:
                        return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.login.RememberMe }));

                    case SignInStatus.Failure:
                    default:
                        ModelState.AddModelError("", "Invalid login attempt.");
                        return(View(model));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Confirm email address by clicking on link sent to yur email id.");
                }
            }
            return(View(model));
        }