Beispiel #1
0
        //
        // GET: /KultiEvents/Edit/5
        public ActionResult Edit(int id = 0)
        {
            Events events = db.Events.Single(e => e.EventId == id);

            if (events == null)
            {
                return(HttpNotFound());
            }

            var  hlpView   = new HelpersViewModel();
            bool isInGroup = false;
            int  GrpId     = events.EvGroupId ?? 0;

            if (HlpView.GetUserId(User.Identity.Name) == events.EvUserId || events.EvGroupId < 1)
            {
                isInGroup = true;
            }

            if (!isInGroup) //make shure that current user belongs to group who created event
            {
                var           roles = (SimpleRoleProvider)Roles.Provider;
                List <string> getRolesOfCurrentUser = roles.GetRolesForUser(User.Identity.Name).ToList();
                foreach (string s in getRolesOfCurrentUser)
                {
                    if (HlpView.GetParamValueByPk(GrpId) == s)
                    {
                        isInGroup = true;
                        break;
                    }
                }
            }

            if (!isInGroup)
            {
                ViewBag.NotAllowed = "Du kannst den Event nicht ändern, da er von einer anderen Gruppe erstellt wurde.";
                return(View("Index", db.Events.ToList()));
            }

            var viewModel = new EditEventViewModel
            {
                CEvents = events,
                Status  = HlpView.Status,
                Type    = HlpView.EventType,
                Size    = HlpView.EventSize,
                Group   = HlpView.Group,
                Agency  = hlpView.Agency,
                SelectedLocationValue = events.EvLocation,
                SelectedStatusValue   = events.EvStatus,
                SelectedTypeValue     = events.EvType,
                SelectedSizeValue     = events.EvSize,
                SelectedGroupValue    = events.EvGroupId,
                SelectedAgencyValue   = events.EvAgencyId,
                EventLocations        = HlpView.GetLocations(events.EventId),
                Docs = HlpView.LstDocsOfEvent(events.EventId)
            };

            return(View(viewModel));
        }
Beispiel #2
0
        public ActionResult ResetPasswort(string username, string email)
        {
            try
            {
                var hplv = new HelpersViewModel();

                //check credentials
                int    userid = hplv.GetUserId(username);
                string sEmail = getCurrentEmail(userid);

                //generate new password & send by email
                if (sEmail.ToLower() == email.ToLower())
                {
                    string newpassword       = Membership.GeneratePassword(8, 0);
                    string confirmationToken = WebSecurity.GeneratePasswordResetToken(username, 1440);
                    WebSecurity.ResetPassword(confirmationToken, newpassword);
                    MailMessage m = new MailMessage();
                    m.BodyFormat = MailFormat.Html;
                    m.From       = "*****@*****.**";
                    m.Subject    = "Passwort erstellt";
                    m.Body       = "Hier das neue Passwort, du kannst es jederzeit ändern:<br/>" + newpassword;
                    m.Body      += "<br/>L.G. Kulti";
                    m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
                    m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "*****@*****.**");
                    m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Bass5494");
                    //To reset your password click on this link http://localhost/Account/ResetPasswordConfirmation/@ViewBag.ConfirmationToken
                    m.To = email.ToLower();
                    SmtpMail.SmtpServer = "localhost";
                    SmtpMail.Send(m);
                    ViewBag.Confirm = "ok";
                    return(View("ResetPasswort"));
                }
                ViewBag.Confirm = "false";
                return(View("ResetPasswort"));
            }
            catch
            {
                ViewBag.Confirm = "false";
                return(View("ResetPasswort"));
            }
        }