public bool Create(PracticeType model) { try { if (model == null) { return(false); } var create = practiceTypeDAL.Create(model); return(create); } catch { return(false); } }
public JsonResult AddPractice(long PracticeID, long SemesterID) { var check = practiceService.GetByLoaiTTvaHocKy(PracticeID, SemesterID); if (check == null) { var practice = new PracticeType { PracticeID = PracticeID, SemesterID = SemesterID }; bool status = practiceService.Create(practice); // 5. Trả về các Link được phân trang theo kích thước và số trang. return(Json(status, JsonRequestBehavior.AllowGet)); } return(Json("Loại thực tập này đã có trong kì học", JsonRequestBehavior.AllowGet)); }
public bool Create(PracticeType model) { try { //Initialization empty item var item = new PracticeType(); //Set value for item with value from model item.PracticeID = model.PracticeID; item.SemesterID = model.SemesterID; //Add item to entity context.PracticeTypes.Add(item); //Save to database context.SaveChanges(); return(true); } catch { return(false); } }
/// <summary> /// Practice a skill. Has a random chance of improving the skill. /// </summary> /// <param name="skill"></param> public void PracticeSkill( Skill skill, PracticeType practiceType ) { if( IsNPC() || practiceType == PracticeType.none) { return; } int aptitude = 0; if (((PC)this).SkillAptitude.ContainsKey(skill.Name)) { aptitude = ((PC)this).SkillAptitude[skill.Name]; } int chance = 5 + (GetCurrInt() / 10); // Modify for difficulty. We can't do anything about 'only on success', so we assume it // succeeded if they made it into this function. switch (practiceType) { default: break; case PracticeType.easy: chance *= 2; break; case PracticeType.difficult: chance /= 2; break; } // Have to be below the max and below 95% and make a successful // skill check and be able to have the skill. if (HasLevelForSkill(skill) && (aptitude < Limits.MAX_SKILL_ADEPT) // Cap skill gains at 26 + 2x the number of levels the char is past gaining the skill. && aptitude < (26 + (2 * Level - skill.ClassAvailability[(int)CharacterClass.ClassNumber])) && MUDMath.NumberRange( 1, 1000 ) <= ( 5 + ( GetCurrInt() / 10 ) ) ) { ((PC)this).SkillAptitude[skill.Name] = aptitude + 1; string buf = "&+cYe feel yer skill in " + skill.Name + " improving.&n\r\n"; SendText( buf ); } return; }
/// <summary> /// Practice a skill by name. /// </summary> /// <param name="name"></param> public void PracticeSkill(string name, PracticeType practiceType) { // Can only practice a skill if it exists. if (Skill.SkillList.ContainsKey(name)) { PracticeSkill(Skill.SkillList[name], practiceType); } }
/// <summary> /// Makes a skill check with the specified modifier and automatically practices the skill in the process. /// </summary> /// <param name="skillName"></param> /// <param name="modifier"></param> /// <returns></returns> public bool CheckSkill(String skillName, int modifier, PracticeType practiceType) { if (!IsNPC()) { PC pc = (PC)this; if (!HasSkill(skillName)) { return false; } bool success = (MUDMath.NumberPercent() < pc.SkillAptitude[skillName]); if (practiceType != PracticeType.only_on_success || success) { PracticeSkill(skillName, practiceType); } return success; } else { if (!HasSkill(skillName)) { return false; } int chance = GetSkillChance(skillName); if (MUDMath.NumberPercent() < chance) { return true; } return false; } }
public bool CheckSkill(String skillName, PracticeType practiceType) { return CheckSkill(skillName, 0, practiceType); }