Ejemplo n.º 1
0
        public ActionResult GetDetail(string name)
        {
            var user     = AspUserManager.FindByEmail(name);
            var userData = _userManager.GetUserDataById(user.Id);

            var jsonData = new
            {
                UserFirstName  = user.FirstName,
                UserLastName   = user.LastName,
                UserEmail      = user.Email,
                UserCity       = user.City,
                UserStreet     = user.Street + " " + user.HouseNumber,
                UserPostalCode = user.PostalCode,
                UserPhone      = user.PhoneNumber,

                CounselorData = userData.Counselor != null ? userData.Counselor.FirstName + " " + userData.Counselor.LastName : "Brak wpisu",

                SchoolName       = userData.School.Name,
                SchoolClass      = userData.School.Class,
                SchoolCity       = userData.School.City,
                SchoolStreet     = userData.School.Street + " " + userData.School.HouseNumber,
                SchoolPostalCode = userData.School.PostalCode,
                SchoolPhone      = userData.School.Phone,

                UserBan = user.LockoutEndDateUtc.HasValue ? user.LockoutEndDateUtc.Value.ToString("HH:mm:ss, dd.MM.yyyy") : "Nie zablokowany"
            };

            return(Json(jsonData));
        }
Ejemplo n.º 2
0
        public ActionResult UnBan(string name)
        {
            var userId = AspUserManager.FindByEmail(name).Id;

            AspUserManager.SetLockoutEndDate(userId, DateTimeOffset.MinValue);

            MvcHtmlString returnValue = Alert.GetAlert(SetAlert.Set("Poprawnie odblokowano " + name, "Sukces", AlertType.Success));

            return(Json(new { Message = returnValue.ToHtmlString() }));
        }
Ejemplo n.º 3
0
        public ActionResult Ban(string name, string banTime, string banDate, bool isPernament)
        {
            MvcHtmlString alert = null;

            if (isPernament)
            {
                var user = AspUserManager.FindByEmail(name);
                AspUserManager.SetLockoutEndDate(user.Id, DateTimeOffset.MaxValue);

                alert = Alert.GetAlert(SetAlert.Set("Pernamentnie zbanowano " + name, "Sukces", AlertType.Success));
            }
            else
            {
                DateTime endDate;
                string   dateAndTime = banDate + " " + banTime;
                bool     parseResult = DateTime.TryParse(dateAndTime, out endDate);

                if (parseResult)
                {
                    if (endDate >= DateTime.Now)
                    {
                        var user = AspUserManager.FindByEmail(name);
                        AspUserManager.SetLockoutEndDate(user.Id, endDate);

                        alert = Alert.GetAlert(SetAlert.Set("Poprawnie zablokowano " + name, "Sukces", AlertType.Success));
                    }
                    else
                    {
                        alert = Alert.GetAlert(SetAlert.Set("Musisz podać datę większą od dnia dzisiejszego", "Błąd", AlertType.Danger));
                    }
                }
                else
                {
                    alert = Alert.GetAlert(SetAlert.Set("Data lub godzina została podana błędnie. Schemat: dd-mm-rrrr hh:ss", "Błąd", AlertType.Danger));
                }
            }

            return(Json(new { Message = alert.ToHtmlString() }));
        }