Ejemplo n.º 1
0
        public static (double, DemandeurIdentite) AttribScoreForOneCandidat(Demandeur demandeur)
        {
            var publicationId          = demandeur.Publications.Select(p => p.Id);
            var PublicationsCollection = new PublicationCollection();
            var publications           = PublicationsCollection.GetItems(p => publicationId.Contains(p.Id)).ToList();
            var like    = 0;
            var ranking = 0.0;

            foreach (var p in publications)
            {
                foreach (var c in p.Commentaires)
                {
                    var predictedCommentaire = new PredictedModels.PredictedCommentaire(c.Commentaire);
                    predictedCommentaire = predictedCommentaire.AttribScoreAndTypeOfComment();
                    ranking += predictedCommentaire.Score;
                }
                like += p.Likes.Where(l => l.Etat == true).Count();
            }
            return(ranking + like, demandeur.Identite);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Register(RegisterViewModel model, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                IdentityResult result;

                // Switch on Selected Account type
                switch (model.AccountType)
                {
                // Volunteer Account type selected:
                case MapDomain.Entities.AccountType.Client:

                {
                    // create new volunteer and map form values to the instance
                    User v = new Client {
                        AccountType = "Client", UserName = model.Email, Email = model.Email
                    };
                    result = await UserManager.CreateAsync(v, model.Password);

                    // Add volunteer role to the new User
                    if (result.Succeeded)
                    {
                        // UserManager.AddToRole(v.Id, EAccountType.Patient.ToString());
                        await SignInManager.SignInAsync(v, isPersistent : false, rememberBrowser : false);

                        // Email confirmation here

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


                // Ngo Account type selected:
                case AccountType.Resource:
                {
                    //System.Diagnostics.Debug.WriteLine("log data here");

                    //  model.CurriculumVitae = image.FileName;

                    // System.Diagnostics.Debug.WriteLine("2");

                    // create new Ngo and map form values to the instance

                    // User res = new Ressource { AccountType= "Resource", UserName = model.Email, Email = model.Email };

                    User res = new Ressource {
                        AccountType = "Resource",
                        UserName    = model.UserName,
                        Email       = model.Email,
                        ProfileT    = model.ProfileT,
                        Seniority   = model.Seniority,
                        // CurriculumVitae=model.CurriculumVitae
                    };


                    /*
                     * var path = Path.Combine(Server.MapPath("~/Content/UploadFile/"), image.FileName);
                     * image.SaveAs(path);
                     */



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



                    // Add Ngo role to the new User
                    if (result.Succeeded)
                    {
                        //     UserManager.AddToRole(ngo.Id, EAccountType.Doctor.ToString());
                        await SignInManager.SignInAsync(res, isPersistent : false, rememberBrowser : false);

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

                break;


                case AccountType.Demandeur:
                {
                    User res = new Demandeur
                    {
                        AccountType = "Demandeur",
                        UserName    = model.UserName,
                        Email       = model.Email,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        PassPort    = model.PassPort,
                        Country     = model.Country,
                        WorkType    = model.WorkType,
                    };
                    result = await UserManager.CreateAsync(res, model.Password);

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

                        return(RedirectToAction("Index", "Home"));
                    }
                }

                break;
                }
            }


            return(View(model));
        }