Esempio n. 1
0
        public async Task <UserDataLoginVM> FindUserDataLogin(string userName)
        {
            CorparateRepository corprepo = new CorparateRepository();
            var userData = await corprepo.FindUserDataLogin(userName);

            return(userData);
        }
Esempio n. 2
0
        public async Task <IdentityUser> FindUser(string userName, string password)
        {
            CorparateRepository corprepo = new CorparateRepository();
            IdentityUser        user     = await _userManager.FindAsync(userName, password);

            return(user);
        }
Esempio n. 3
0
        public async Task <IdentityResult> CreateUserOnlyForAdmins(User userModel)
        {
            CorparateRepository corprepo = new CorparateRepository();
            IdentityUser        user     = new IdentityUser
            {
                UserName = userModel.UserName,
            };
            //Saving the user to the ASP.NET user tables
            var result = await _userManager.CreateAsync(user, userModel.Password);

            //If above was successfull then we will add the user accounts
            if (result.Succeeded)
            {
                //Set the user id to the ASP.net User id
                userModel.UserId = user.Id;

                //set User's active = false
                userModel.Activated = true;

                //- Create Approval Entry for given Org to visible to Supper User

                await corprepo.CreateUserOnly(userModel);
            }

            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// This will create a buyer and the organisation at the same time.
        /// </summary>
        /// <param name="userModel"></param>
        /// <returns></returns>
        public async Task <IdentityResult> CreateUserOnly(User userModel)
        {
            try
            {
                CorparateRepository corprepo = new CorparateRepository();
                var          path            = System.Configuration.ConfigurationManager.AppSettings["ActivationPath"];
                IdentityUser user            = new IdentityUser
                {
                    UserName = userModel.UserName,
                };
                //Saving the user to the ASP.NET user tables
                var result = await _userManager.CreateAsync(user, userModel.Password);

                //If above was successfull then we will add the user accounts
                if (result.Succeeded)
                {
                    //Set the user id to the ASP.net User id
                    userModel.UserId = user.Id;


                    //check orgId is a valied one.
                    bool orgValied = await corprepo.CheckOrganizationExits(userModel.OrganizationID);

                    if (!orgValied)
                    {
                        //IdentityUser useride = new IdentityUser(userModel.UserName);
                        var xres = _userManager.Delete(user);
                        throw new Exception("Invalied Organization");
                    }
                    //set User's active = false
                    userModel.Activated = false;
                    //Set supperuser false by defualt. becouse system not allowed more than one supper user for organization
                    //This controller create users for existing orgs and 100% certenty that the org has supperuser already
                    userModel.IsSupperUser = false;

                    //- Create Approval Entry for given Org to visible to Supper User

                    await corprepo.CreateUserOnly(userModel);

                    //Send an email
                    await corprepo.SendMail(new EmailVM()
                    {
                        UserId = userModel.UserId, ToAddress = userModel.Email
                    }, path);
                }
                else
                {
                    throw new Exception("User name you have given is already taken from another user.PleaseTry different user name ");
                }

                return(result);
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// This will create a buyer and the organisation at the same time.
        /// </summary>
        /// <param name="userModel"></param>
        /// <returns></returns>
        public async Task <IdentityResult> CreateBuyerWithOrganisation(OrgUserFullVM userModel)
        {
            IdentityUser user = new IdentityUser
            {
                UserName = userModel.UserDet.UserName,
            };
            //Saving the user to the ASP.NET user tables
            var result = await _userManager.CreateAsync(user, userModel.UserDet.Password);

            //Set the user id to the ASP.net User id
            userModel.UserDet.UserId           = user.Id;
            userModel.OrganisazionDet.IsSeller = false;
            //If above was successfull then we will add the organization and our detail user accounts
            if (result.Succeeded)
            {
                //Manually set the org type
                userModel.OrganisazionDet.IsSeller = false;
                CorparateRepository corprepo = new CorparateRepository();
                await corprepo.CreateUserWithOrganisation(userModel);
            }

            return(result);
        }
 /// <summary>
 /// constructor of the controller
 /// </summary>
 public CorparateController()
 {
     corepo = new CorparateRepository();
 }
Esempio n. 7
0
 public SiteTestController()
 {
     corepo = new CorparateRepository();
 }