Beispiel #1
0
        public ActionResult Register(RegisterModel model)
        {
            log.Info("POST - UserController - Register");
            ActionResult result = View(model);

            try
            {
                switch (UserAdministration.Register(
                            model.FirstName,
                            model.LastName,
                            model.GamerTag,
                            model.Username,
                            model.Password))
                {
                case RegisterResult.Successful:
                    TempData[Constants.MessageType.SUCCESS] = Messages.SUCCESS_REGISTER;
                    result = RedirectToAction("Index", "Shop");
                    break;

                case RegisterResult.UsernameExists:
                    TempData[Constants.MessageType.WARNING] = Messages.WARNING_USERNAME_EXISTS;
                    break;

                case RegisterResult.NotSet:
                default:
                    break;
                }
            }
            catch (Exception)
            {
                TempData[Constants.MessageType.ERROR] = Messages.ERROR_REGISTER;
            }
            return(result);
        }
Beispiel #2
0
 public bool Signup(UserAdministration user)
 {
     user.Password = BCrypt.Net.BCrypt.HashPassword(user.Password);
     _dbContext.UserAdministrations.Add(user);
     _dbContext.SaveChanges();
     return true;
 }
Beispiel #3
0
        public ActionResult Login(LoginModel model)
        {
            log.Info("POST - UserController - Login");
            ActionResult result = RedirectToAction("Index", "Shop");

            string returnUrl = Request.Params["ReturnUrl"];

            if (returnUrl != null)
            {
                result = Redirect(returnUrl);
            }

            try
            {
                switch (UserAdministration.Login(model.Username, model.Password))
                {
                case LoginResult.Successful:
                    #region get user roles, create authentication ticket, encrypt it
                    /// setze auth cookie
                    UserRole userRole = RolesAdministration.GetUserRole(model.Username);
                    if (userRole != null)
                    {
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                         model.Username,
                                                                                         DateTime.Now,
                                                                                         DateTime.Now.AddMinutes(30),
                                                                                         true,
                                                                                         userRole.Name,
                                                                                         FormsAuthentication.FormsCookiePath);

                        // Encrypt the ticket.
                        string encTicket = FormsAuthentication.Encrypt(ticket);

                        // Create the cookie.
                        Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
                    }

                    TempData[Constants.MessageType.SUCCESS] = Messages.SUCCESS_LOGIN;
                    break;

                    #endregion
                case LoginResult.InvalidPassword:
                case LoginResult.InvalidUsername:
                    TempData[Constants.MessageType.WARNING] = Messages.ERROR_LOGIN;
                    break;

                case LoginResult.NotSet:
                    break;

                default:
                    break;
                }
            }
            catch (Exception)
            {
                TempData[Constants.MessageType.ERROR] = Messages.ERROR_COMMON;
            }

            return(result);
        }
Beispiel #4
0
        public ActionResult SupervisorAdmin()
        {
            Users user   = CMSService.GetUserByUserName(username);
            int   userId = 0;

            if (user != null)
            {
                userId = user.UserId;
            }
            List <int> ContractIds = new List <int>();

            ContractIds = CMSService.GetContractsByUserId(userId);

            UserAdministration ua = new UserAdministration();



            List <viewUser> UserList = CMSService.GetSupervisorAdmin(ContractIds);

            ua.UsersToReview    = UserList.Where(x => x.IsActive == false && x.IsApproved == false).ToList();
            ua.Users            = UserList.Where(x => x.IsActive == true && ContractIds.Any(c => x.UserContracts.Any(uc => uc.ContractId == c && uc.IsActive == true))).ToList();
            ua.UsersDisApproved = UserList.Where(x => x.IsDisApproved == true && x.IsActive == false).ToList();
            ua.UsersInactive    = UserList.Where(x => x.IsActive == false && x.IsApproved == true).ToList();
            List <int> SupervisorContractIds = CMSService.GetContractsByUserId(user.UserId);

            ua.Contracts = CMSService.GetContracts().Where(c => SupervisorContractIds.Contains(c.Id)).ToList();

            return(View(ua));
        }
Beispiel #5
0
        public ActionResult Edit()
        {
            log.Info("GET - UserController - Edit");
            ActionResult result = View();

            string username = User.Identity.Name;

            try
            {
                User currentUser = UserAdministration.GetUser(username);

                /// map userinformation to UserEditModel

                /// pass it to view()
            }
            catch (Exception ex)
            {
                if (ex is ArgumentNullException || ex is ArgumentException)
                {
                    TempData[Constants.MessageType.ERROR] = Messages.ERROR_UNKNOWN_USER;
                }
                else if (ex is Exception)
                {
                    TempData[Constants.MessageType.ERROR] = Messages.ERROR_COMMON;
                }

                result = RedirectToAction("Index", "Shop");
            }

            return(result);
        }
Beispiel #6
0
        public ActionResult RAAAdmin()
        {
            Users user   = CMSService.GetUserByUserName(username);
            int   userId = 0;

            if (user != null)
            {
                userId = user.UserId;
            }
            List <int> RAAIds = new List <int>();

            RAAIds = CMSService.GetPSAsByUserId(userId);

            UserAdministration ua = new UserAdministration();



            List <viewUser> UserList = CMSService.GetRAAAdmin(RAAIds);

            ua.UsersToReview    = UserList.Where(x => x.IsActive == false && x.IsApproved == false).ToList();
            ua.Users            = UserList.Where(x => x.IsActive == true && RAAIds.Any(c => x.UserPSA.PSAId == c && x.UserPSA.isActive == true)).ToList();
            ua.UsersDisApproved = UserList.Where(x => x.IsDisApproved == true && x.IsActive == false).ToList();
            ua.UsersInactive    = UserList.Where(x => x.IsActive == false && x.IsApproved == true).ToList();
            ua.PSAs             = CMSService.GetPSAs().Where(c => RAAIds.Contains(c.Id)).ToList();

            return(View(ua));
        }
        public void TestIfaRegistrationofanUserWorks()
        {
            string email = $"User{(DateTime.Now).ToString()}@bla.at";

            UserAdministration.Register("Franzi", email, "Franz", "Huber", "Zippererstrasse 3", "Wien", 1110, "zumFranz", DateTime.Now, "11111");
            User user = Flitter.LOGIC.Manager.UserManager.Get_UserByEmail(email);

            Assert.IsNotNull(user);
            Assert.AreEqual(email, user.Email);
        }
Beispiel #8
0
        //Users

        public ActionResult UserAdmin()
        {
            UserAdministration ua = new UserAdministration();

            ua.UsersToReview    = CMSService.GetUsersForReview();
            ua.Users            = CMSService.GetUsers();
            ua.UsersDisApproved = CMSService.GetDisApprovedUsers();
            ua.UsersInactive    = CMSService.GetInactiveUsers();

            return(View(ua));
        }
Beispiel #9
0
        public ActionResult Packs()
        {
            log.Info("GET - Shop - Packs");
            PackOverviewModel model = null;


            try
            {
                /// get data from logic
                List <CardPack> packs       = ShopAdministration.GetCardPacks();
                User            currentUser = UserAdministration.GetUser(User.Identity.Name);

                /// MAP data to view model
                /// in this case mapping will be done manually
                /// BUT you may make use of an automapper too
                model = new PackOverviewModel()
                {
                    AmountMoney = currentUser.AmountMoney
                };

                List <PackModel> packsModel = new List <PackModel>();

                foreach (var pack in packs)
                {
                    packsModel.Add(new PackModel()
                    {
                        Description = pack.Name,
                        Name        = pack.Name,
                        Price       = pack.Price,
                        ID          = pack.ID
                    });
                }
                model.Packs = packsModel;
            }
            catch (Exception)
            {
                TempData[Constants.MessageType.ERROR] = Messages.ERROR_COMMON;
            }

            return(View(model));
        }
Beispiel #10
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        UserAdministration objUsrAdmin = new UserAdministration();

        objUsrAdmin.UserId      = Convert.ToUInt16(Session["UsrID"]);
        objUsrAdmin.OldPassword = txtOldPwd.Text;
        objUsrAdmin.Password    = txtNewPwd.Text;
        try
        {
            string strMsg;
            strMsg      = objUsrAdmin.ChangePassword();
            lblMsg.Text = strMsg;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            objUsrAdmin = null;
        }
    }
Beispiel #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Set Page Heading
        Label lbl = (Label)this.Master.FindControl("lblPageHeading");

        lbl.Text = "Manage User";

        //TV: 04/2009 - added message Label to display informative (non-error) messages to the user
        lblMsg.Text = "";

        if (!IsPostBack)
        {
            //Populate Federation dropdown
            DataSet dsFed;
            _objGen               = new General();
            dsFed                 = _objGen.get_AllFederations();
            ddlFed.DataSource     = dsFed;
            ddlFed.DataTextField  = "Federation";
            ddlFed.DataValueField = "ID";
            ddlFed.DataBind();
            if ((ddlFed.Items.Count != 0))
            {
                ddlFed.Items.Insert(0, new ListItem("--Select--", "-1"));
            }

            ddlMovement.DataSource = MovementDAL.GetAllMovement();
            ddlMovement.DataBind();
            ddlMovement.Items.Insert(0, new ListItem("--Select--", "-1"));
        }
        else
        {
            //TV: 04/2009 - Task # A-046 - check to see if was saved in a prior screen
            if (Session["objUsrAdmin"] != null)
            {
                _objUsrAdmin = (UserAdministration)Session["objUsrAdmin"];
            }
        }
    }
Beispiel #12
0
 public Login(UserAdministration user)
 {
     this.user = user;
     this.Build();
 }
 public bool SignUp([FromBody] UserAdministration user)
 {
     user.CompId = Guid.Parse("02CE1048-96F3-4E46-8EDE-C65EAB8E04A7");
     user.UserId = Guid.NewGuid();
     return(_userService.Signup(user));
 }
Beispiel #14
0
        public UserAdministration RemovedAdministration(UserAdministration administration)
        {
            _context.Entry(administration).State = EntityState.Deleted;

            return(administration);
        }
Beispiel #15
0
        public UserAdministration AddedAdministration(UserAdministration administration)
        {
            _context.Entry(administration).State = EntityState.Added;

            return(administration);
        }