Наследование: MonoBehaviour
Пример #1
0
 void putTargetData(Experience targetData)
 {
     enemyView.SetActive (true);
     enemyName.text = targetData.lvl + " : " + targetData.xpName;
     enemyGauge.anchorMax = new Vector2 ((1f / targetData.maxLife) * targetData.life, lifeGauge.anchorMax.y);
     enemyLife.text = targetData.life + " / " + targetData.maxLife;
 }
 public void add(Experience exp)
 {
     foreach (KeyValuePair<string, int> pair in exp.expTotals)
     {
         this.add(pair.Key, pair.Value);
     }
 }
 public Experience(Experience e)
 {
     this.b = e.GetBehavior ();
     this.target = e.GetTarget ();
     this.models = e.GetGameObjects ();
     this.owner = e.GetOwner ();
 }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     xp = GameObject.FindGameObjectWithTag ("Player").GetComponent<Experience> ();
     sk = GameObject.FindGameObjectWithTag ("Player").GetComponent<skillScript> ();
     for (int i = 0; i < sk.skills.Length; i++)
     {
         fields[i].text = sk.skills[i].name;
         levels[i].text = sk.skills[i].level.ToString ();
     }
 }
    public static Experience DefaultExperience()
    {
        Experience e = new Experience();
        foreach (int value in Enum.GetValues(typeof(Dimension)))
        {
            e.add(((Dimension)value).GetDescription(), 0);
        }

        return e;
    }
Пример #6
0
        public UserCharacter(Character character)
        {
            this.character = character;
            this.professions = new List<Profession.Profession>();
            this.exp = new Experience(0);

            this.bonusPoint = Parameter.zero;

            this.currentParameter = character.tribe.parameter;
        }
Пример #7
0
 public static void Edit(Experience pExperience)
 {
     SqlCommand SQLCmd = new SqlCommand();
     SQLCmd.CommandType = CommandType.StoredProcedure;
     SQLCmd.CommandText = "UpdateExperience";
     SQLCmd.Parameters.Add("Id", SqlDbType.Int).Value = pExperience.Id;
     SQLCmd.Parameters.Add("Name", SqlDbType.VarChar, 100).Value = pExperience.Name;
     BaseDataAccess.OpenConnection(SQLCmd);
     BaseDataAccess.ExecuteNonSelect(SQLCmd);
     BaseDataAccess.CloseConnection();
 }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     if (enemySpawned == null) {
         isGrounded = false;
     } else {
         isGrounded = true;
     }
     if (spawnRef == null) {
         spawnRef = GameObject.FindGameObjectWithTag("Player").GetComponent<Experience>();
     }
     reachTime = Random.Range (spawnTimeMin, spawnTimeMax);
 }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     locker = GetComponentInParent<LockGates>();
     locked = true;
     anim = GetComponent<Animation>();
     player = GameObject.Find ("Warrior");
     roomspawner = GameObject.Find("Room Spawner").GetComponent<RoomSpawner>();
     enemies = GameObject.Find ("Spawner").GetComponent<SpawnEnemies>();
     exp = GameObject.Find ("Warrior").GetComponent<Experience>();
     ga = GameObject.Find ("Spawner").GetComponent<GeneticAlgorithm>();
     enemyspawner = GameObject.Find ("Spawner").GetComponent<SpawnEnemies>();
 }
Пример #10
0
 void Start()
 {
     if (playerExperience != null)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         playerExperience = this;
         DontDestroyOnLoad(transform.root.gameObject);
     }
 }
Пример #11
0
	void Awake()
	{
		mc = GetComponent<MoveController> ();
		ac = GetComponent<AttackController> ();
		tm = GetComponent<TeamMember> ();
		hp = GetComponent<Health> ();
		xp = GetComponent<Experience> ();
		an = GetComponent<Animator> ();
		rb = GetComponent<Rigidbody2D> ();
		sr = GetComponent<SpriteRenderer> ();
		bc = GetComponent<BoxCollider2D> ();

	}
Пример #12
0
        public static Experience Parse(SqlDataReader dr)
        {
            Experience Experience = new Experience();

            Experience.Id = Convert.ToInt32(dr["Id"]);
            Experience.CandidateId = Convert.ToInt32(dr["CandidateId"]);
            Experience.TypeId = (ExperienceType)Convert.ToInt32(dr["TypeId"]);

            Experience.Name = Convert.ToString(dr["Name"]);
            Experience.Type = Convert.ToString(dr["Type"]);

            return Experience;
        }
    public Slide(Slide s)
    {
        this.text = s.text;
        this.gui = s.gui;
        this.parent = s.parent;
        s.experience.SetOwner (this);
        this.experience = (Experience) Activator.CreateInstance(s.experience.GetType(), s.experience);
        this.question = s.question;
        this.state = s.state;

        if (this.state == SlideState.DONE) {
            this.state = SlideState.AR;
        }
    }
Пример #14
0
        public static int Create(Experience pExperience)
        {
            SqlCommand SQLCmd = new SqlCommand();
            SQLCmd.CommandType = CommandType.StoredProcedure;
            SQLCmd.CommandText = "CreateExperience";
            SQLCmd.Parameters.Add("CandidateId", SqlDbType.Int).Value = pExperience.CandidateId;
            SQLCmd.Parameters.Add("TypeId", SqlDbType.Int).Value = (int)pExperience.TypeId;
            SQLCmd.Parameters.Add("Name", SqlDbType.VarChar, 100).Value = pExperience.Name;
            SQLCmd.Parameters.Add("Id", SqlDbType.Int).Direction = ParameterDirection.Output;
            BaseDataAccess.OpenConnection(SQLCmd);
            BaseDataAccess.ExecuteNonSelect(SQLCmd);
            BaseDataAccess.CloseConnection();

            return Convert.ToInt32(SQLCmd.Parameters["Id"].Value);
        }
Пример #15
0
    public void makeDamage(Experience target)
    {
        int damage;
        int agy;

        agy = agility;
        if (armInfo != null) {
            agy += (int)((float)agy * armInfo.powerMultiplier.agility);
        }
        damage = 0;
        if (75 + agy - target.agility >= Random.Range (0, 100)) {
            damage = Random.Range (minDamage, maxDamage) * (1 - target.armor / 200);
        }
        target.takeDamage(damage);
    }
    // Update is called once per frame
    public void Change(int ? id = null)
    {
        if (id == null)
            playerid = 0;
        else
            playerid = (int)id;
        Player_PF = main_process.GetPlayerObject(id);
        Player_Script = main_process.GetPlayerScript(id);
        Player_EXP = main_process.GetPlayerExperience(id);
        Player_Health = Player_PF.GetComponent<Health>();
        Player_Mana = Player_PF.GetComponent<Mana>();
        Player_Defense = Player_PF.GetComponent<Defense>();
        Player_ATK = Player_Script.AttackCollider.GetComponent<DealDamage>();

        //if (!Player_ATK)
        //    Debug.Log("Cannot Get Player_ATK");
        ATK.text = Player_Script.GetTotalStrength().ToString();
        DEF.text = Player_Defense.defense.ToString();
        STA.text = Player_Script.GetTotalStamina().ToString();
        SPI.text = Player_Script.GetTotalIntelligence().ToString();
        AGI.text = Player_Script.GetTotalAgility().ToString();
        BATK.text = "<color=#ffffffff>" + Player_ATK.GetDamageI().ToString() + "-" + Player_ATK.GetDamageI().ToString() + "</color>";
        MATK.text = "<color=#ffffffff>" + Player_ATK.GetDamageI().ToString() + "-" + Player_ATK.GetDamageI().ToString() + "</color>";
        PDEF.text = Player_Defense.GetPhysicalDefense().ToString();
        MDEF.text = Player_Defense.GetMagicalDefense().ToString();
        //CRIR.text = (Player_ATK.GetCriticalChance()*100).ToString()+"%";
        C_ICON.sprite = CI.Class_info[Player_Script.GetClassID()].icon;
        C_HP.text = Player_Health.GetCurrentHealth().ToString() + "/" + Player_Health.GetMaxHP().ToString();
        CRIR.text = "0.00%";
        C_MP.text = Player_Mana.GetMana().ToString() + "/" + Player_Mana.MaxMana.ToString();
        C_LV.text = Player_EXP.GetCurrentLevel().ToString();
        C_EXP.text = Player_EXP.GetExperience().ToString();
        C_NEXP.text = (Player_EXP.GetNEXP()-Player_EXP.GetExperience()).ToString();
        C_Name.text = Player_Script.Player_Name;
        weapon.sprite = CI.Class_info[Player_Script.GetClassID()].weapon[Player_Script.GetWeaponLV()].icon;
        amror.sprite = CI.Class_info[Player_Script.GetClassID()].armor[Player_Script.GetAmrorLV()].icon;
        accer.sprite = CI.Class_info[Player_Script.GetClassID()].accessory[Player_Script.GetAccessoriesLV()].icon;
        C_PASP.text = Player_PF.GetComponent<PassiveSkillManager>().getAvailablePoints().ToString();
        select_current = 1;
        gem_selecting = false;
        passive_selecting = false;
        gem_system.manager = main_process.GetPlayerGemManager(playerid);
    }
Пример #17
0
 // Use this for initialization
 void Start()
 {
     if (player == null) {
         player = FindObjectOfType<movePlayer>().GetComponent<Experience>();
     }
     if (anim == null) {
         anim = GetComponent<Animator>();
     }
     if (nma == null) {
         nma = GetComponent<NavMeshAgent>();
     }
     if (attackPoint > attackTime) {
         attackPoint = attackTime;
     }
     if (stat == null) {
         stat = GetComponent<Experience>();
     }
     if (stat.xpName.Length <= 0) {
         stat.xpName = gameObject.name;
     }
 }
Пример #18
0
        public static void Create(string experience)
        {
            if (experience.Length == 0) { throw new Exception("Invalid experience."); }

            JobBoardDataContext db = new JobBoardDataContext();

            // Make sure we don't already have a experience entry for this
            int existing = db.Experiences.Where(x => x.experience1 == experience).Count();
            if (existing > 0) { throw new Exception("Existing entry."); }

            // Create new experience level
            Experience exp = new Experience {
                id = Guid.NewGuid(),
                experience1 = experience,
                date_added = DateTime.Now
            };

            // Save experience
            db.Experiences.InsertOnSubmit(exp);
            db.SubmitChanges();
        }
Пример #19
0
 public Experience AddExperience(Experience experience)
 {
     try
     {
         if (experience != null)
         {
             VestnDB db = new VestnDB();
             db.experience.Add(experience);
             db.SaveChanges();
             return experience;
         }
         else
         {
             return null;
         }
     }
     catch (Exception e)
     {
         logAccessor.CreateLog(DateTime.Now, "userAccessor - AddExperience", e.StackTrace);
         return null;
     }
 }
Пример #20
0
 public void Init(Skill _skill, Experience _xp)
 {
     skill = _skill;
     playerXP = _xp;
 }
Пример #21
0
 public IActionResult Post([FromBody] Experience experience)
 {
     _context.Experience.Add(experience);
     _context.SaveChanges();
     return(Ok(_context.Experience.ToList()));
 }
Пример #22
0
 void Start()
 {
     xp = GetComponent<Experience>();
 }
 public BundleFileException(Experience experience, Exception innerException) : base(DefaultMessage, innerException)
 {
     Experience = experience;
 }
Пример #24
0
        public static List <Experience> GetAllExperiencesByCand(int idCand)
        {
            // création connection
            using (SqlConnection sqlConnect = Connection.GetConnection())
            {
                List <Experience> lstExperiences = new List <Experience>();
                using (SqlCommand sqlCde = new SqlCommand())
                {
                    //initialiser la connection de la commande
                    sqlCde.Connection = sqlConnect;
                    // chargement des qualifications
                    String strSql = "GetAllExperiencesByCand";
                    sqlCde.CommandText = strSql;
                    sqlCde.CommandType = CommandType.StoredProcedure;
                    sqlCde.Parameters.Add(new SqlParameter("@idCandidat", SqlDbType.Int)).Value = idCand;

                    // Exécution de la commande
                    try
                    {
                        SqlDataReader sqlRdr      = sqlCde.ExecuteReader();
                        Experience    oExperience = null;
                        while (sqlRdr.Read())
                        {
                            // Qualification
                            Qualification oQualif = new Qualification()
                            {
                                IdQualification      = sqlRdr.GetInt32(2),
                                LibelleQualification = sqlRdr[8].ToString()
                            };
                            // Entreprise
                            Entreprise oEntreprise = new Entreprise()
                            {
                                IdEntreprise  = idCand,
                                RaisonSociale = sqlRdr[7].ToString()
                            };
                            // date fin null ?
                            DateTime?df;
                            if (!sqlRdr.IsDBNull(5))
                            {
                                df = sqlRdr.GetDateTime(5);
                            }
                            else
                            {
                                df = null;
                            }


                            // Création objet
                            oExperience = new Experience()
                            {
                                IdExperience = sqlRdr.GetInt32(0),
                                IdCandidat   = idCand,
                                DateDebut    = sqlRdr.GetDateTime(4),
                                DateFin      = df,
                                Commentaire  = sqlRdr[6].ToString(),
                                LaQualif     = oQualif,
                                Lentreprise  = oEntreprise
                            };
                            lstExperiences.Add(oExperience);
                        }
                        sqlRdr.Close();

                        return(lstExperiences);
                    }
                    catch (SqlException se)
                    {
                        throw new DaoExceptionFinAppli("Lecture Experience impossible \n" + se.Message, se);
                    }
                }
            }
        }
Пример #25
0
    public LocalObject(string _uniqueName, Race _race, CharacterClass _cclass, Background _background, Origin _origin, int experience)
    {
        uniqueName = _uniqueName;
        race = _race;
        cclass = _cclass;
        background = _background;
        origin = _origin;

        xp = new Experience(experience, this);

        skills = new Skills(this);
        inventory = new Inventory(6, 1, "", true, null, this);

        hp = new HPComponent(this);
        movement = new Movement(this);
        defence = new Defence(this);
        attack = new Attack(this);
        abilities = new Abilities(this);
        fatigue = new Fatigue(this);
        eating = new Eating(this);
    }
Пример #26
0
        private static void PopulateDb(FluentConfiguration config)
        {
            using (var session = config.BuildSessionFactory().OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    PopulateLookups(session);

                    var studentRole = new Role(RoleNames.Student)
                    {
                        Name = "Student"
                    };
                    var instructorRole = new Role(RoleNames.Instructor)
                    {
                        Name = "Instructor"
                    };
                    var adminRole = new Role(RoleNames.Administrator)
                    {
                        Name = "Administrator"
                    };
                    session.SaveOrUpdate(studentRole);
                    session.SaveOrUpdate(instructorRole);
                    session.SaveOrUpdate(adminRole);

                    var user = new User {
                        Identifier = "postit"
                    };
                    user.Profile = new Profile(user)
                    {
                        FirstName = "Scott",
                        LastName  = "Kirkland",
                        Email     = "*****@*****.**",
                        ImageUrl  = WebConfigurationManager.AppSettings["DefaultProfilePictureUrl"]
                    };
                    user.Roles.Add(studentRole);

                    session.SaveOrUpdate(user);

                    var hermes = new User {
                        Identifier = "hconrad"
                    };
                    hermes.AssociateProfile(new Profile(hermes)
                    {
                        FirstName = "Hermes",
                        LastName  = "Conrad",
                        Email     = "*****@*****.**",
                        ImageUrl  = WebConfigurationManager.AppSettings["DefaultProfilePictureUrl"]
                    });
                    hermes.Roles.Add(instructorRole);

                    session.SaveOrUpdate(hermes);

                    var farnsworth = new User {
                        Identifier = "hfarnsworth"
                    };
                    farnsworth.AssociateProfile(new Profile(farnsworth)
                    {
                        FirstName = "Hubert",
                        LastName  = "Farnsworth",
                        Email     = "*****@*****.**",
                        ImageUrl  = WebConfigurationManager.AppSettings["DefaultProfilePictureUrl"]
                    });

                    session.SaveOrUpdate(farnsworth);

                    var instructor = new Instructor
                    {
                        FirstName  = "Hubert",
                        LastName   = "Farnsworth",
                        Email      = "*****@*****.**",
                        Identifier = "hfarnworth",
                        User       = farnsworth
                    };

                    var instructor2 = new Instructor
                    {
                        FirstName  = "Hermes",
                        LastName   = "Conrad",
                        Email      = "*****@*****.**",
                        Identifier = "hconrad",
                        User       = hermes
                    };

                    session.SaveOrUpdate(instructor);
                    session.SaveOrUpdate(instructor2);

                    var etype = new ExperienceType {
                        Name = "Exploration", Icon = "icon-flag"
                    };
                    session.SaveOrUpdate(etype);
                    session.SaveOrUpdate(new ExperienceType {
                        Name = "Collaboration", Icon = "icon-group"
                    });

                    var outcome = new Outcome {
                        Name = "Outcome 1", Description = "Some outcome", ImageUrl = string.Empty
                    };
                    session.SaveOrUpdate(outcome);
                    session.SaveOrUpdate(new Outcome
                    {
                        Name        = "Super Skills",
                        Description = "Pretty good skillz",
                        ImageUrl    = string.Empty
                    });

                    var experience = new Experience
                    {
                        Creator        = user,
                        ExperienceType = etype,
                        Name           = "Sample Experience",
                        Description    = "This is a bit of text about exactly what I did in this experience",
                        Start          = DateTime.Now,
                        Location       = "moab, ut",
                        CoverImageUrl  = "https://ucdbadges.blob.core.windows.net/publicimagesdev/e600f3de-a969-45af-b70b-7d2f5285e572"
                    };

                    experience.AddInstructor(instructor);
                    experience.AddInstructor(instructor2);

                    session.SaveOrUpdate(experience);

                    //Badges
                    var category = new BadgeCategory
                    {
                        Name     = "SampleCategory",
                        ImageUrl = "https://ucdbadges.blob.core.windows.net/publicimagesdev/12da4d70-207a-45e5-b6e4-f1b418c1802a"
                    };

                    session.SaveOrUpdate(category);

                    var badge = new Badge
                    {
                        Approved    = true,
                        Category    = category,
                        CreatedOn   = DateTime.UtcNow,
                        Name        = "First Badge",
                        Description = "Really interesting badge for being awesome",
                        Creator     = user,
                        ImageUrl    = "https://ucdbadges.blob.core.windows.net/publicimagesdev/12da4d70-207a-45e5-b6e4-f1b418c1802a"
                    };

                    badge.AddCriteria("You need to do a, b, c");
                    badge.AddCriteria("Also you need to be a human");

                    session.SaveOrUpdate(badge);

                    tx.Commit();
                }
            }
        }
Пример #27
0
        public ActionResult EditExperience(Guid id, Experience experience, HttpPostedFileBase coverImage)
        {
            var experienceToEdit =
                RepositoryFactory.ExperienceRepository.Queryable.SingleOrDefault(
                    x => x.Id == id && x.Creator.Identifier == CurrentUser.Identity.Name);

            if (experienceToEdit == null)
            {
                return new HttpNotFoundResult("Could not find the requested experience");
            }

            experienceToEdit.Instructors.Clear(); //"reset" with given instructor list
            UpdateModel(experienceToEdit, "Experience");

            if (ModelState.IsValid)
            {
                if (coverImage != null)
                {
                    experienceToEdit.CoverImageUrl = CropAndSave(coverImage, CoverPictureWidth, CoverPictureHeight);
                }

                experienceToEdit.LastModified = DateTime.UtcNow;
                RepositoryFactory.ExperienceRepository.EnsurePersistent(experienceToEdit);

                Message = "Experience Updated!";
                return RedirectToAction("ViewExperience", "Student", new {id});
            }

            var model = GetEditModel(experience);

            return View(model);
        }
Пример #28
0
 private ExperienceEditModel GetEditModel(Experience experience)
 {
     return new ExperienceEditModel
     {
         User = _userService.GetCurrent(),
         Experience = experience,
         Instructors = RepositoryFactory.InstructorRepository.GetAll(),
         ExperienceTypes = RepositoryFactory.ExperienceTypeRepository.GetAll()
     };
 }
Пример #29
0
 public IActionResult Create(Experience Experience)
 {
     //  db.Experiences.Add(Experience);
     db.SaveChanges();
     return(RedirectToAction("Index", "Location"));
 }
Пример #30
0
    IEnumerator attackEnemy()
    {
        isAttack = true;
        Experience copy;

        copy = targetEnemy;
        yield return new WaitForSeconds (attackPoint);
        if (copy != null && copy.life > 0 && Vector3.Distance (transform.position, copy.transform.position) < nma.stoppingDistance) {
            stat.makeDamage(copy);
            if (copy.life <= 0) {
                stat.addXP(copy.xp);
                stat.money += copy.money;
                if (targetEnemy == copy) {
                    targetEnemy = null;
                }
            }
        }
        yield return new WaitForSeconds (attackTime - attackPoint);
        isAttack = false;
    }
Пример #31
0
 public IActionResult Update(Experience Experience)
 {
     db.Entry(Experience).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Details", "Location", new { id = Experience.LocationId }));
 }
 public BundleAsyncLoadOperation(Experience experience) : base(experience)
 {
     mExperience = experience ?? throw new ArgumentNullException("experience");
     CoroutineService.Instance.StartCoroutine(DoLoad(experience.Bytes, experience.CompressionType));
 }
 public BundleFileException(Experience experience) : this(experience, DefaultMessage)
 {
     Experience = experience;
 }
Пример #34
0
        int get_max_level()
        {
            int current_level = Experience.GetCreatureLevel(fXP / fParty.Size);

            return(Math.Max(fParty.Level + 5, current_level + 1));
        }
Пример #35
0
        public ActionResult AddExperience(Experience experience, HttpPostedFileBase coverImage)
        {
            if (ModelState.IsValid)
            {
                if (coverImage != null)
                {
                    experience.CoverImageUrl = CropAndSave(coverImage, CoverPictureWidth, CoverPictureHeight);
                }

                RepositoryFactory.ExperienceRepository.EnsurePersistent(experience);

                Message = "Experience Added!";
                return RedirectToAction("ViewExperience", "Student", new {id = experience.Id});
            }

            var model = GetEditModel(experience);

            return View(model);
        }
        public string UpdateExperience(int experienceId = -1, string propertyId = null, string propertyValue = null , string token = null)
        {
            if (Request.RequestType.Equals("OPTIONS", StringComparison.InvariantCultureIgnoreCase))
            {
                return null;
            }
            try
            {
                int authUserId = -1;
                if (token != null)
                {
                    authUserId = authenticationEngine.authenticate(token);
                }
                else
                {
                    return AddErrorHeader("An authentication token must be passed in", 2);
                }
                if (authUserId < 0)
                {
                    return AddErrorHeader("You are not authenticated, please log in!", 2);
                }
                Experience exp = new Experience();
                if (experienceId > 0)
                {
                    exp = userManager.GetExperience(experienceId);
                }
                else
                {
                    return AddErrorHeader("An experienceId must be passed in", 1);
                }
                if (exp.userId != authUserId)
                {
                    return AddErrorHeader("User is not authorized to exit this experience", 3);
                }
                System.Reflection.PropertyInfo pi;
                if(propertyId == null)
                {
                    return AddErrorHeader("A propertyId must be passed in", 1);
                }
                else
                {
                    pi = exp.GetType().GetProperty(propertyId);
                }
                if(propertyValue == null)
                {
                    return AddErrorHeader("A propertyValue must be passed in", 1);
                }
                else
                {
                    if(propertyId == "startDate" || propertyId == "endDate")
                    {
                        pi.SetValue(exp, Convert.ChangeType(DateTime.Parse(propertyValue), pi.PropertyType), null);
                    }
                    else
                    {
                        pi.SetValue(exp, Convert.ChangeType(propertyValue, pi.PropertyType), null);
                    }
                    Experience exp1 = userManager.UpdateExperience(exp);
                    JsonModels.Experience returnExp = userManager.GetExperienceJson(exp1.id);
                    string ret = Serialize(returnExp);
                    return AddSuccessHeader(ret);
                }

            }
            catch(Exception ex)
            {
                logAccessor.CreateLog(DateTime.Now, "userController - updateExperience", ex.StackTrace);
                return AddErrorHeader("Something went wrong while updating this experience element", 1);
            }
        }
Пример #37
0
 public bool Navigate(Experience experience, object param = null)
 {
     return this.navigationService.Navigate(experience.ToString(), param);
 }
Пример #38
0
        public NewsViewModel GetAdministratorModel()
        {
            NewsViewModel news = new NewsViewModel();

            List <Question> allRequests = db.Questions.Where(q => q.Approved == false).ToList();

            if (User.IsInRole("Supervisor"))
            {
                List <Question> requests     = new List <Question>();
                int             departmentId = db.Users.Find(User.Identity.GetUserId()).AdminDepartmentId;
                List <int>      jobIds       = db.Jobs.Where(j => j.DepartmentId == departmentId).Select(j => j.JobId).ToList();
                foreach (int jobId in jobIds)
                {
                    requests.AddRange(allRequests.Where(q => q.JobId == jobId));
                }
                allRequests = requests;
            }
            news.Requests = allRequests;

            List <Interview> interviews = db.Interviews.Where(i => i.Candidate.IsActive && i.IsDone && !i.IsGraded).ToList();

            if (User.IsInRole("Supervisor"))
            {
                int departmentId = db.Users.Find(User.Identity.GetUserId()).AdminDepartmentId;
                interviews = interviews.Where(i => i.Job.DepartmentId == departmentId).ToList();
            }
            news.Interviews = interviews;

            /*
             * var candidatesToDelete = db.Users.Where(u => u.CandidateInterviewId == 0).ToList();
             * if (candidatesToDelete.Count() > 0)
             * {
             *  foreach(var candidate in candidatesToDelete)
             *  {
             *      if(candidate.IsInRole("Candidate"))
             *          new UsersController().Delete(candidate.Id, Url.Action("GetAdministratorModel","News"));
             *  }
             * }
             */
            List <ApplicationUser> allCandidates = db.Users.Where(c => c.IsActive == false && c.CandidateInterview.IsGraded == false).ToList();

            if (User.IsInRole("Supervisor"))
            {
                List <ApplicationUser> candidates = new List <ApplicationUser>();
                int        departmentId           = db.Users.Find(User.Identity.GetUserId()).AdminDepartmentId;
                List <int> jobIds = db.Jobs.Where(j => j.DepartmentId == departmentId).Select(j => j.JobId).ToList();
                foreach (int jobId in jobIds)
                {
                    candidates.AddRange(allCandidates.Where(c => c.CandidateInterview.JobId == jobId));
                }
                allCandidates = candidates;
            }
            news.Candidates = allCandidates;

            List <Experience> experiences = new List <Experience>();

            foreach (var candidate in allCandidates)
            {
                Experience experience = db.Experiences.Where(e => e.CandidateId == candidate.Id).First();
                experiences.Add(experience);
            }
            news.Experiences = experiences;

            return(news);
        }
 public void SetExperience(Experience experience)
 {
     this.experience = experience;
 }
 public BundleFileException(Experience experience, string message) : base(message)
 {
     Experience = experience;
 }
Пример #41
0
        private static void PopulateDb(FluentConfiguration config)
        {
            using (var session = config.BuildSessionFactory().OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    PopulateLookups(session);

                    var studentRole = new Role(RoleNames.Student) {Name = "Student"};
                    var instructorRole = new Role(RoleNames.Instructor) {Name = "Instructor"};
                    var adminRole = new Role(RoleNames.Administrator) {Name = "Administrator"};
                    session.SaveOrUpdate(studentRole);
                    session.SaveOrUpdate(instructorRole);
                    session.SaveOrUpdate(adminRole);

                    var user = new User {Identifier = "postit"};
                    user.Profile = new Profile(user)
                        {
                            FirstName = "Scott",
                            LastName = "Kirkland",
                            Email = "*****@*****.**",
                            ImageUrl = WebConfigurationManager.AppSettings["DefaultProfilePictureUrl"]
                        };
                    user.Roles.Add(studentRole);

                    session.SaveOrUpdate(user);

                    var hermes = new User {Identifier = "hconrad"};
                    hermes.AssociateProfile(new Profile(hermes)
                        {
                            FirstName = "Hermes",
                            LastName = "Conrad",
                            Email = "*****@*****.**",
                            ImageUrl = WebConfigurationManager.AppSettings["DefaultProfilePictureUrl"]
                        });
                    hermes.Roles.Add(instructorRole);

                    session.SaveOrUpdate(hermes);

                    var farnsworth = new User { Identifier = "hfarnsworth" };
                    farnsworth.AssociateProfile(new Profile(farnsworth)
                    {
                        FirstName = "Hubert",
                        LastName = "Farnsworth",
                        Email = "*****@*****.**",
                        ImageUrl = WebConfigurationManager.AppSettings["DefaultProfilePictureUrl"]
                    });

                    session.SaveOrUpdate(farnsworth);

                    var instructor = new Instructor
                        {
                            FirstName = "Hubert",
                            LastName = "Farnsworth",
                            Email = "*****@*****.**",
                            Identifier = "hfarnworth",
                            User = farnsworth
                        };

                    var instructor2 = new Instructor
                    {
                        FirstName = "Hermes",
                        LastName = "Conrad",
                        Email = "*****@*****.**",
                        Identifier = "hconrad",
                        User = hermes
                    };

                    session.SaveOrUpdate(instructor);
                    session.SaveOrUpdate(instructor2);

                    var etype = new ExperienceType { Name = "Exploration", Icon = "icon-flag" };
                    session.SaveOrUpdate(etype);
                    session.SaveOrUpdate(new ExperienceType {Name = "Collaboration", Icon = "icon-group"});

                    var outcome = new Outcome {Name = "Outcome 1", Description = "Some outcome", ImageUrl = string.Empty};
                    session.SaveOrUpdate(outcome);
                    session.SaveOrUpdate(new Outcome
                        {
                            Name = "Super Skills",
                            Description = "Pretty good skillz",
                            ImageUrl = string.Empty
                        });

                    var experience = new Experience
                        {
                            Creator = user,
                            ExperienceType = etype,
                            Name = "Sample Experience",
                            Description = "This is a bit of text about exactly what I did in this experience",
                            Start = DateTime.Now,
                            Location = "moab, ut",
                            CoverImageUrl = "https://ucdbadges.blob.core.windows.net/publicimagesdev/e600f3de-a969-45af-b70b-7d2f5285e572"
                        };

                    experience.AddInstructor(instructor);
                    experience.AddInstructor(instructor2);

                    session.SaveOrUpdate(experience);

                    //Badges
                    var category = new BadgeCategory
                        {
                            Name = "SampleCategory",
                            ImageUrl = "https://ucdbadges.blob.core.windows.net/publicimagesdev/12da4d70-207a-45e5-b6e4-f1b418c1802a"
                        };

                    session.SaveOrUpdate(category);

                    var badge = new Badge
                        {
                            Approved = true,
                            Category = category,
                            CreatedOn = DateTime.UtcNow,
                            Name = "First Badge",
                            Description = "Really interesting badge for being awesome",
                            Creator = user,
                            ImageUrl = "https://ucdbadges.blob.core.windows.net/publicimagesdev/12da4d70-207a-45e5-b6e4-f1b418c1802a"
                        };

                    badge.AddCriteria("You need to do a, b, c");
                    badge.AddCriteria("Also you need to be a human");

                    session.SaveOrUpdate(badge);

                    tx.Commit();
                }

            }
        }
 public void DoSynchronizeExpLevel()
 {
     this.ExpLevel = Experience.GetLevelForPoints(this.ExpPoints);
 }
Пример #43
0
 public ExperienceViewModel(Experience experience)
 {
     Experience = experience;
     experience.Responsibilities.ToList().ForEach(i => Responsibilities.Add(new ResponsobilityViewModel(i)));
 }