Exemplo n.º 1
0
        // GET: Parrain/Home
        public ActionResult Index()
        {
            ViewBag.title = "Area Parrain - Marraine";
            ParrainModel          parainM = new ParrainModel(); // donc contient :  IsConnected + package
            UtilisateurRepository ur      = new UtilisateurRepository(ConfigurationManager.ConnectionStrings["My_Asptest_Cnstr"].ConnectionString);

            // 1.
            parainM.Utilisateur = mapToVIEWmodels.utilisateurTOprofileModel(ur.getOne(SessionUtilisateur.ConnectedUser.IdUtilisateur));
            // 2.
            if (SessionUtilisateur.ConnectedUserPackage != null)
            {
                FormuleRepository fr = new FormuleRepository(ConfigurationManager.ConnectionStrings["My_Asptest_Cnstr"].ConnectionString);
                parainM.ThePackage = mapToVIEWmodels.formuleToFormuleModel(fr.getOne(SessionUtilisateur.ConnectedUserPackage.IdFormule));
            }
            // 3.
            if (SessionUtilisateur.ConnectedUserAnimals != null)
            {
                AnimalRepository ar = new AnimalRepository(ConfigurationManager.ConnectionStrings["My_Asptest_Cnstr"].ConnectionString);
                foreach (AnimalModel item in SessionUtilisateur.ConnectedUserAnimals)
                {
                    AnimalModel AnimalfromDB = mapToVIEWmodels.animalToAnimalModel(ar.getOne(item.IdAnimal));
                    parainM.AnimauxAdoptes.ToList().Add(AnimalfromDB);
                }
            }

            return(View(parainM));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                ParrainModel    parrain = null;
                ApplicationUser user    = null;
                //add Parrain when register if exist
                if (!string.IsNullOrWhiteSpace(model.ParrainName))
                {
                    IDal dal = new Dal();
                    parrain = dal.GetParrainList().FirstOrDefault(m => m.ParrainEmail == model.ParrainName);
                    user    = new ApplicationUser {
                        UserName = model.Email.ToLower(), Email = model.Email.ToLower(), PhoneNumber = model.Phone, FirstName = model.FirstName, Parrain_Id = parrain.Id, Date_Create_Account = DateTime.Now
                    };
                }
                else
                {
                    user = new ApplicationUser {
                        UserName = model.Email.ToLower(), Email = model.Email.ToLower(), PhoneNumber = model.Phone, FirstName = model.FirstName, Date_Create_Account = DateTime.Now
                    };
                }


                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // Pour plus d'informations sur l'activation de la confirmation de compte et de la réinitialisation de mot de passe, visitez https://go.microsoft.com/fwlink/?LinkID=320771
                    // Envoyer un message électronique avec ce lien
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    //await UserManager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                    string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirmez votre compte", model.Email);

                    ViewBag.Message = "Vérifier votre email et confirmer, vous devez absolument confirmer " +
                                      "avant de vous connecter et déposer votre première annonce.";


                    return(View("Info"));

                    // return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> RegisterWithSmS(RegisterViewModel model)
        {
            ParrainModel    parrain = null;
            ApplicationUser user    = null;
            var             rand    = new Random();
            var             randd   = rand.Next(1000000).ToString();

            //add Parrain when register if exist
            if (!string.IsNullOrWhiteSpace(model.ParrainName))
            {
                IDal dal = new Dal();
                parrain = dal.GetParrainList().FirstOrDefault(m => m.ParrainEmail == model.ParrainName);
                user    = new ApplicationUser {
                    UserName = "******" + randd + "@mail.cm", Email = "Mtest" + randd + "@mail.cm", FirstName = model.FirstName, Parrain_Id = parrain.Id, Date_Create_Account = DateTime.Now
                };
            }
            else
            {
                user = new ApplicationUser {
                    UserName = "******" + randd + "@mail.cm", Email = "Mtest" + randd + "@mail.cm", FirstName = model.FirstName, Date_Create_Account = DateTime.Now
                };
            }

            var result = await UserManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                //If everythings is ok then ask to user to confirm sms
                return(RedirectToAction("AddPhoneNumberFirstRegister", "Manage"));
            }
            AddErrors(result);

            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> AddParrain(ParrainViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await dal.GetUsersList().FirstOrDefaultAsync(m => m.Email == model.Email);

                if (user != null)
                {
                    var parrain = new ParrainModel()
                    {
                        Date_createParrain = DateTime.Now,
                        ParrainEmail       = user.Email,
                        ParrainFirstName   = user.FirstName
                    };
                    dal.AddParrain(parrain);
                    return(RedirectToAction("ListAllAgents"));
                }
                else
                {
                    return(RedirectToAction("ListAllAgents"));
                }
            }
            return(RedirectToAction("ListAllAgents"));
        }