Пример #1
0
        public virtual async Task <Execute <string> > SignUp([FromBody] SignUpEntity signUpEntity)
        {
            var signUp = await LoginBusiness.SignUpAsync(signUpEntity);

            var result = new Execute <string>(signUp);

            if (!result.HasErro)
            {
                result.Entity = TicketManager.WriteToken(signUp.Entity);
            }

            return(result);
        }
Пример #2
0
        public bool SaveSignUp(SignUpModel sm)
        {
            SignUpEntity signUp = new SignUpEntity();

            signUp.Rue       = sm.Rue;
            signUp.Numero    = sm.Numero;
            signUp.Ville     = sm.Ville;
            signUp.CP        = sm.CP;
            signUp.Nom       = sm.Nom;
            signUp.Prenom    = sm.Prenom;
            signUp.Email     = sm.Email;
            signUp.DateNaiss = sm.DateNaiss;
            signUp.Photo     = sm.Photo;
            signUp.Password  = sm.Password;
            signUp.Login     = sm.Login;
            signUp.Telephone = sm.Telephone;

            return(_signUpRepo.Insert(signUp));
        }
Пример #3
0
        public async Task <Execute <TicketEntity> > SignUpAsync(SignUpEntity signUp)
        {
            var result = new Execute <TicketEntity>();

            if (!await ValidateSignUp.IsSatisfiedByAsync(signUp, result))
            {
                return(result);
            }

            var(person, user, provider) = await CastNewUser(signUp);

            using (var db = new Context.XCommonDbContext())
            {
                using (var transaction = await db.Database.BeginTransactionAsync())
                {
                    result.AddMessage(await PeopleBusiness.SaveAsync(person, db));
                    result.AddMessage(await UsersBusiness.SaveAsync(user, db));
                    result.AddMessage(await UsersProvidersBusiness.SaveAsync(provider, db));

                    if (!result.HasErro)
                    {
                        transaction.Commit();
                    }
                }
            }

            if (!result.HasErro)
            {
                result.Entity = new TicketEntity
                {
                    Culture = person.Culture,
                    Key     = person.IdPerson,
                    Name    = person.Name,
                    Roles   = await GetUserRolesAsync(user)
                };
            }

            return(result);
        }
        public ActionResult UserSignUp(string FirstName, string LastName, string Phone, string Email, string Password, string RePassword, string Gender, string BirthDate)
        {
            try
            {
                if (Password != RePassword)
                {
                    TempData["msgAlert"]            = "N";
                    TempData["msgAlertDetails"]     = "Password did not matched";
                    Session["SessionUserId"]        = null;
                    Session["SessionUserEmail"]     = null;
                    Session["SessionUserFirstName"] = null;
                    Session["SessionUserFullName"]  = null;
                    Session["SessionUserType"]      = null;
                    return(RedirectToAction("Login", "Security"));
                }
                SignUpEntity signUpEntity = new SignUpEntity();
                signUpEntity.FirstName  = FirstName;
                signUpEntity.LastName   = LastName;
                signUpEntity.Phone      = Phone;
                signUpEntity.Email      = Email;
                signUpEntity.Password   = Password;
                signUpEntity.Gender     = Gender;
                signUpEntity.BirthDate  = BirthDate;
                signUpEntity.NickName   = "";
                signUpEntity.UserId     = "0";
                signUpEntity.UserType   = "customer";
                signUpEntity.UserStatus = "Y";

                var res = apiRequest.HttpPostRequest(signUpEntity, "api/Security/UserSignUp");
                // response = response.Replace("null", "0");
                string response      = res.ToString();
                var    responseModel = JsonConvert.DeserializeObject <ResponseMessage>(response);

                if (responseModel.MessageCode == "Y")
                {
                    TempData["msgAlert"]        = "Y";
                    TempData["msgAlertDetails"] = responseModel.Message.ToString();

                    return(RedirectToAction("Login", "Security"));
                }


                else
                {
                    TempData["msgAlert"]            = "N";
                    TempData["msgAlertDetails"]     = responseModel.Message.ToString();
                    Session["SessionUserId"]        = null;
                    Session["SessionUserEmail"]     = null;
                    Session["SessionUserFirstName"] = null;
                    Session["SessionUserFullName"]  = null;
                    Session["SessionUserType"]      = null;
                    return(RedirectToAction("SignUp", "Security"));
                }
            }
            catch (Exception ex)
            {
                TempData["msgAlert"]            = "N";
                TempData["msgAlertDetails"]     = "Sorry, something wrong. Please wait and try after a few minutes.";
                Session["SessionUserId"]        = null;
                Session["SessionUserEmail"]     = null;
                Session["SessionUserFirstName"] = null;
                Session["SessionUserFullName"]  = null;
                Session["SessionUserType"]      = null;
                return(RedirectToAction("SignUp", "Security"));
            }
            return(RedirectToAction("SignUp", "Security"));
        }
Пример #5
0
 public Task <Execute <TicketEntity> > SignUpAsync(SignUpEntity signUp)
 {
     throw new NotImplementedException();
 }
Пример #6
0
        protected virtual async Task <(PeopleEntity person, UsersEntity user, UsersProvidersEntity provider)> CastNewUser(SignUpEntity signUp)
        {
            var person = new PeopleEntity
            {
                Action       = EntityAction.New,
                IdPerson     = Guid.NewGuid(),
                Name         = signUp.Name,
                Email        = signUp.Email,
                Birthday     = signUp.BirthDay,
                Culture      = signUp.Language,
                Gender       = signUp.Male ? GenderType.Male : GenderType.Female,
                CreatedAt    = DateTime.Now,
                ChangedAt    = DateTime.Now,
                ImageCover   = signUp.UrlCover,
                ImageProfile = signUp.UrlImage
            };

            var user = new UsersEntity
            {
                Action            = EntityAction.New,
                IdUser            = person.IdPerson,
                IdPerson          = person.IdPerson,
                AccessFailedCount = 0,
                EmailConfirmed    = false,
                LockoutEnabled    = false,
                PasswordHash      = string.Empty,
                PhoneConfirmed    = false,
                ProfileComplete   = false
            };

            if (signUp.Provider == ProviderType.Local)
            {
                user.PasswordHash = await GetPasswordHashAsync(user, signUp.Password);
            }

            var userProvider = new UsersProvidersEntity
            {
                Action           = EntityAction.New,
                IdUserProvide    = Guid.NewGuid(),
                IdUser           = person.IdPerson,
                Provider         = signUp.Provider,
                ProviderDefault  = true,
                ProviderToken    = signUp.Token,
                ProviderUrlCover = signUp.UrlCover,
                ProviderUrlImage = signUp.UrlImage
            };

            return(await Task.FromResult((person, user, userProvider)));
        }