protected void AdminPw(object sender, EventArgs e)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            _context = new fbLudoDBEntities3();
            Code code;

            code = _context.Code.FirstOrDefault(x => x.Code1 == Password2.Text && x.Aktiv == true);

            if (code == null)
            {
                FailureText2.Text     = "Ungültiger Code";
                ErrorMessage2.Visible = true;
            }
            else
            {
                var manager     = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var currentUser = manager.FindById(User.Identity.GetUserId());
                var result      = UserManager.AddToRole(currentUser.Id, "Admin");
                var result2     = UserManager.AddToRole(currentUser.Id, "Mitglied");
                Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                Response.Redirect("Account/Login.aspx?mode=logout");
            }
        }
        protected void ReedemCode(object sender, EventArgs e)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            _context = new fbLudoDBEntities3();
            Code code;

            code = _context.Code.FirstOrDefault(x => x.Code1 == Code.Text && x.Aktiv == true);

            if (code == null)
            {
                FailureText.Text     = "Ungültiger Code";
                ErrorMessage.Visible = true;
            }
            else
            {
                var manager     = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var currentUser = manager.FindById(User.Identity.GetUserId());
                var result      = UserManager.AddToRole(currentUser.Id, "Mitglied");
                code.Aktiv = false;
                _context.Entry(code).State = EntityState.Modified;
                _context.SaveChanges();
                SuccessText.Text       = "Sie sind nun Mitglied!";
                SuccessMessage.Visible = true;
                Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                Response.Redirect("Account/Login.aspx?mode=logout");
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var manager     = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var currentUser = manager.FindById(User.Identity.GetUserId());

            if (currentUser != null)
            {
                if (currentUser.FirstLogin == false)
                {
                    Response.Redirect("/Account/Manage?m=AddData");
                }
                else
                {
                    if (!Page.IsPostBack)
                    {
                        var userId = User.Identity.GetUserId();
                        _context = new fbLudoDBEntities3();
                        IEnumerable <Spiel> list = _context.Spiel.Where(x => x.Ausgeliehen == false).ToList();

                        RadioButtonList.DataSource     = list;
                        RadioButtonList.DataTextField  = "Name";
                        RadioButtonList.DataValueField = "Spiel_ID";
                        RadioButtonList.AutoPostBack   = false;
                        RadioButtonList.DataBind();
                    }
                }
            }
            else
            {
                Response.Redirect("/");
            }
        }
Beispiel #4
0
        private void LoadData(string userId)
        {
            DateTime now = DateTime.Now;

            _context = new fbLudoDBEntities3();
            IEnumerable <Ausleihe>       listAusleihen;
            IEnumerable <Ausleihe_Spiel> list = Enumerable.Empty <Ausleihe_Spiel>();

            listAusleihen = _context.Ausleihe.Where(x => x.PersonenID == userId).ToList();

            foreach (Ausleihe ausleiheid in listAusleihen)
            {
                var id = ausleiheid.Ausleihe_ID;

                if (list == null)
                {
                    list = _context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis > now).ToList();
                }
                else
                {
                    list = list.Concat(_context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis > now).ToList());
                }
            }

            EmployeesListView.DataSource = list;
            EmployeesListView.DataBind();


            IEnumerable <Ausleihe>       listAusleihenInactive;
            IEnumerable <Ausleihe_Spiel> listInactive = Enumerable.Empty <Ausleihe_Spiel>();

            listAusleihenInactive = _context.Ausleihe.Where(x => x.PersonenID == userId).ToList();

            foreach (Ausleihe ausleiheid in listAusleihenInactive)
            {
                var id = ausleiheid.Ausleihe_ID;

                if (listInactive == null)
                {
                    listInactive = _context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis <= now).ToList();
                }
                else
                {
                    listInactive = listInactive.Concat(_context.Ausleihe_Spiel.Where(x => x.Ausleihe_ID == id && x.DatumBis <= now).ToList());
                }
            }
            ListView2.DataSource = listInactive;
            ListView2.DataBind();



            /*IEnumerable<Ausleihe> list2 = _context.Ausleihe.Where(x => x.PersonenID == userId && x.DatumBis <= now).ToList();
             * ListView2.DataSource = list2;
             * ListView2.DataBind();*/
        }
Beispiel #5
0
        protected void GenerateCode(object sender, EventArgs e)
        {
            Code code = new Code()
            {
                Code1         = Membership.GeneratePassword(10, 2),
                Aktiv         = true,
                IsCode        = true,
                IsMitarbeiter = false,
                IsAdmin       = false
            };

            _context = new fbLudoDBEntities3();
            _context.Code.Add(code);
            _context.SaveChanges();
            SuccessText.Text       = code.Code1;
            SuccessMessage.Visible = true;
        }
Beispiel #6
0
        public void back(Object sender, EventArgs e)
        {
            var id    = (sender as LinkButton).CommandArgument;
            var idInt = int.Parse(id);

            _context = new fbLudoDBEntities3();
            var ausleihe = _context.Ausleihe_Spiel.FirstOrDefault(x => x.Ausleihe_ID == idInt);
            var spiel    = _context.Spiel.FirstOrDefault(x => x.Spiel_ID == ausleihe.Spiel_ID);

            spiel.Ausgeliehen = false;
            DateTime newDeadline = DateTime.Now;

            ausleihe.DatumBis = newDeadline;
            _context.Entry(ausleihe).State = EntityState.Modified;
            _context.Entry(spiel).State    = EntityState.Modified;
            _context.SaveChanges();
            Response.Redirect(Request.RawUrl);
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var manager     = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var currentUser = manager.FindById(User.Identity.GetUserId());

            if (currentUser != null)
            {
                if (currentUser.FirstLogin == false)
                {
                    Response.Redirect("/Account/Manage?m=AddData");
                }
                else
                {
                    if (!Page.IsPostBack)
                    {
                        var userId = User.Identity.GetUserId();
                        _context = new fbLudoDBEntities3();
                        IEnumerable <Spiel> list = _context.Spiel.Where(x => x.Ausgeliehen == false).ToList();

                        CheckListSpiele.DataSource     = list;
                        CheckListSpiele.DataTextField  = "Name";
                        CheckListSpiele.DataValueField = "Spiel_ID";
                        CheckListSpiele.AutoPostBack   = false;
                        CheckListSpiele.DataBind();

                        var message = Request.QueryString["m"];
                        if (message != null)
                        {
                            // Abfragezeichenfolge aus der Aktion entfernen
                            Form.Action = ResolveUrl("~/Account/Manage");

                            SuccessMessage =
                                message == "SaveDataSuccess" ? "Die persönlichen Daten wurden erfolgreich gespeichert."
                                : String.Empty;
                            successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage);
                        }
                    }
                }
            }
            else
            {
                Response.Redirect("/");
            }
        }
Beispiel #8
0
        public void longer(Object sender, EventArgs e)
        {
            var id    = (sender as LinkButton).CommandArgument;
            var idInt = int.Parse(id);

            _context = new fbLudoDBEntities3();
            var ausleihe = _context.Ausleihe_Spiel.FirstOrDefault(x => x.Ausleihe_ID == idInt);

            if (ausleihe.AnzVerlaengerungen <= 2)
            {
                System.TimeSpan duration    = new System.TimeSpan(7, 0, 0, 0);
                DateTime        newDeadline = Convert.ToDateTime(ausleihe.DatumBis);
                newDeadline                    = newDeadline.Add(duration);
                ausleihe.DatumBis              = newDeadline;
                ausleihe.AnzVerlaengerungen    = ausleihe.AnzVerlaengerungen + 1;
                _context.Entry(ausleihe).State = EntityState.Modified;
                _context.SaveChanges();
                Response.Redirect(Request.RawUrl);
            }
        }
Beispiel #9
0
        public void ausleihen(Object sender, EventArgs e)
        {
            var      userid      = Context.User.Identity.GetUserId();
            DateTime currentTime = DateTime.Now;

            System.TimeSpan duration = new System.TimeSpan(7, 0, 0, 0);
            DateTime        deadline = currentTime.Add(duration);
            var             counter  = 0;
            var             anzItems = 0;

            foreach (ListItem item in CheckListSpiele.Items)
            {
                if (item.Selected)
                {
                    anzItems++;
                }
            }

            if (anzItems <= 3)
            {
                foreach (ListItem item in CheckListSpiele.Items)
                {
                    if (item.Selected)
                    {
                        //var spielid = int.Parse(DropDownList1.SelectedValue item.Value);
                        //var spielname = Convert.ToString(DropDownList1.SelectedItem);

                        var spielid   = int.Parse(item.Value);
                        var spielname = item.Text;

                        Ausleihe ausleihe = new Ausleihe()
                        {
                            PersonenID = userid
                        };
                        Ausleihe_Spiel ausleihe_spiel = new Ausleihe_Spiel()
                        {
                            Ausleihe_ID        = ausleihe.Ausleihe_ID,
                            Spiel_ID           = spielid,
                            Name               = spielname,
                            DatumVon           = currentTime,
                            DatumBis           = deadline,
                            AnzVerlaengerungen = counter
                        };
                        _context = new fbLudoDBEntities3();
                        _context.Ausleihe.Add(ausleihe);
                        _context.Ausleihe_Spiel.Add(ausleihe_spiel);
                        //_context.SaveChanges();

                        var spiel = _context.Spiel.FirstOrDefault(x => x.Spiel_ID == spielid);
                        spiel.Ausgeliehen           = true;
                        _context.Entry(spiel).State = EntityState.Modified;
                        _context.SaveChanges();
                    }
                }
                Response.Redirect("/AusleihenÜbersicht");
            }
            else
            {
                errormsg.InnerHtml = "Es wurden zu viele Spiele ausgewählt. Es können maximal 3 Spiele ausgelehnt werden.";
            }
        }