Пример #1
0
        //[Authorize(Roles = "Admin,Client")]
        public ActionResult MyProfile(CorporateProfile MyProfile)
        {
            UserViewModel userdetails = generic.GetUserDetail(User.Identity.GetUserId());

            ViewBag.UserId = userdetails.SubscriberId;
            //If Client has team members with all rights
            if (userdetails.CorporateId != null && userdetails.CorporateId != userdetails.SubscriberId)
            {
                var  TeamDetails = cms.GetTeamMember(userdetails.CorporateId, User.Identity.GetUserId()).FirstOrDefault();
                bool result      = cms.AddTeamMember(User.Identity.GetUserId(), userdetails.CorporateId, userdetails.SubscriberId, MyProfile.Name, MyProfile.AlternateEmail, MyProfile.AlternateContact, TeamDetails.EmpRoleId, TeamDetails.Designation, DateTime.UtcNow, User.Identity.GetUserId());
                return(RedirectToAction("MyProfile", "Dashboard", new { area = "CMS", status = result }));
            }
            else
            {
                bool result = cms.AddCorporateProfile(userdetails.UserId, MyProfile.Name, MyProfile.AlternateContact, MyProfile.AlternateEmail, MyProfile.Nationality, MyProfile.DepartmentId, MyProfile.SubscriberId, DateTime.UtcNow, userdetails.UserId);

                if (!string.IsNullOrEmpty(MyProfile.CorporateId))
                {
                    foreach (string file in Request.Files)
                    {
                        HttpPostedFileBase attachment = Request.Files[file] as HttpPostedFileBase;
                        cms.uploadLogo(MyProfile.CorporateId, attachment);
                    }
                }
                return(RedirectToAction("MyProfile", "Dashboard", new { area = "CMS", status = result }));
            }
        }
Пример #2
0
        public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                //var user = UserManager.FindByEmail(model.UserName);
                LoginViewModel user = null;
                if (!String.IsNullOrEmpty(model.UserName))
                {
                    user = admin.GetLoginDetails(model.UserName);
                }

                if (user == null)
                {
                    ModelState.AddModelError("", "User Not Found.");
                }
                else
                {
                    var userDet = UserManager.FindByName(user.UserName);

                    if (!String.IsNullOrEmpty(userDet.Email))
                    {
                        string code = await UserManager.GeneratePasswordResetTokenAsync(userDet.Id);

                        var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = userDet.Id, code = code }, protocol: Request.Url.Scheme);
                        await UserManager.SendEmailAsync(userDet.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        return(RedirectToAction("ForgotPasswordConfirmation", "Account"));
                    }
                    else
                    {
                        //Email the reset request to Admin
                        UserProfile prof    = udbc.UserProfile.Where(p => p.UserId == userDet.Id).FirstOrDefault();
                        string      adminId = prof.SubscriberId;
                        string      code    = await UserManager.GenerateEmailConfirmationTokenAsync(adminId);

                        CorporateProfile subscriber = udbc.CorporateProfile.Where(s => s.CorporateId == adminId).FirstOrDefault();
                        var msgBody = "Dear " + subscriber.Name + ", <br/> <br/> Greetings from Blink! <br/> <br/> USER '" + prof.Name + "' with User Name '" + userDet.UserName + "' has requested for password reset. Please reset the password and share with the user." +
                                      "<br><br>Blink ";
                        await UserManager.SendEmailAsync(adminId, "Reset Password for USER " + userDet.UserName, msgBody);

                        ModelState.AddModelError("", "No valid Email found for this registered user. Request email sent to your Subscriber/Corporate.");
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }