예제 #1
0
 /// <summary>
 /// Retrieves Get Total Rows of Language
 /// </summary>
 /// <returns>Int32 type object</returns>
 public Int32 GetRowCount()
 {
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         return(data.GetRowCount());
     }
 }
예제 #2
0
 /// <summary>
 /// Retrieve list of Language  by PageRequest.
 /// <param name="request"></param>
 /// </summary>
 /// <returns>List of Language</returns>
 public LanguageList GetPaged(PagedRequest request)
 {
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         return(data.GetPaged(request));
     }
 }
예제 #3
0
 /// <summary>
 /// Retrieve list of Language  by query String.
 /// <param name="query"></param>
 /// </summary>
 /// <returns>List of Language</returns>
 public LanguageList GetByQuery(String query)
 {
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         return(data.GetByQuery(query));
     }
 }
예제 #4
0
 /// <summary>
 /// Retrieve list of Language.
 /// no parameters required to be passed in.
 /// </summary>
 /// <returns>List of Language</returns>
 public LanguageList GetAll()
 {
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         return(data.GetAll());
     }
 }
예제 #5
0
 /// <summary>
 /// Retrieve Language data using unique ID
 /// </summary>
 /// <param name="_Id"></param>
 /// <returns>Language Object</returns>
 public Language Get(Int32 _Id)
 {
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         return(data.Get(_Id));
     }
 }
예제 #6
0
 /// <summary>
 /// Delete operation for Language
 /// <param name="_Id"></param>
 /// <returns></returns>
 private bool Delete(Int32 _Id)
 {
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         // return if code > 0
         return(data.Delete(_Id) > 0);
     }
 }
예제 #7
0
        public ActionResult AddLanguage(Language language)
        {
            var list = new LanguageDataAccess().FindAll <Language>();

            language.Id          = list.Count == 0 ? 1 : list.Last().Id + 1;
            language.Name        = Request.Form["Name"];
            language.Description = Request.Form["Description"];
            new LanguageDataAccess().InsertOne(language);
            return(RedirectToAction("Main", "Admin"));
        }
예제 #8
0
        /// <summary>
        /// Retrieve list of Language.
        /// </summary>
        /// <param name="fillChild"></param>
        /// <returns>List of Language</returns>
        public LanguageList GetAll(bool fillChild)
        {
            LanguageList languageList = new LanguageList();

            using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
            {
                languageList = data.GetAll();
            }
            if (fillChild)
            {
                foreach (Language languageObject in languageList)
                {
                    FillLanguageWithChilds(languageObject, fillChild);
                }
            }
            return(languageList);
        }
예제 #9
0
        /// <summary>
        /// Update base of Language Object.
        /// Data manipulation processing for: new, deleted, updated Language
        /// </summary>
        /// <param name="languageObject"></param>
        /// <returns></returns>
        public bool UpdateBase(Language languageObject)
        {
            // use of switch for different types of DML
            switch (languageObject.RowState)
            {
            // insert new rows
            case BaseBusinessEntity.RowStateEnum.NewRow:
                return(Insert(languageObject));

            // delete rows
            case BaseBusinessEntity.RowStateEnum.DeletedRow:
                return(Delete(languageObject.Id));
            }
            // update rows
            using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
            {
                return(data.Update(languageObject) > 0);
            }
        }
예제 #10
0
 /// <summary>
 /// Insert new language.
 /// data manipulation for insertion of Language
 /// </summary>
 /// <param name="languageObject"></param>
 /// <returns></returns>
 private bool Insert(Language languageObject)
 {
     // new language
     using (LanguageDataAccess data = new LanguageDataAccess(ClientContext))
     {
         // insert to languageObject
         Int32 _Id = data.Insert(languageObject);
         // if successful, process
         if (_Id > 0)
         {
             languageObject.Id = _Id;
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #11
0
        public bool Save([FromBody] JObject content)
        {
            try
            {
                dynamic   data      = JsonConvert.DeserializeObject <dynamic>(content.ToString());
                Character character = new Character();
                try
                {
                    character = new CharacterDataAccess().FindOne(data.id);
                }
                catch { }
                character.Id     = data.id;
                character.Name   = data.name;
                character.Age    = data.age == "" ? 0 : data.age;
                character.Height = data.height == "" ? 0 : data.height;
                character.Weight = data.weight == "" ? 0 : data.weight;
                character.MinimunStatusPoints = data.min_status;
                character.MaxPoints           = data.max_points;
                character.CurrentPoints       = data.current_points;
                character.Resources           = data.resources;
                character.Description         = data.description == "" ? "" : data.description;
                character.Status.Add("Strength", (int)data.strength);
                character.Status.Add("Dexterity", (int)data.dexterity);
                character.Status.Add("Intelligence", (int)data.intelligence);
                character.Status.Add("Health", (int)data.health);
                character.Status.Add("MaxLifePoints", (int)data.max_life_points);
                character.Status.Add("CurrentLifePoints", (int)data.current_life_points);
                character.Status.Add("Will", (int)data.will);
                character.Status.Add("Perception", (int)data.perception);
                character.Status.Add("MaxFatiguePoints", (int)data.max_fatigue_points);
                character.Status.Add("CurrentFatiguePoints", (int)data.current_fatigue_points);
                character.Status.Add("Speed", (int)data.speed);
                character.Status.Add("BasicMovement", (int)data.basic_movement);
                character.Status.Add("MaxCarryWeight", (int)data.max_carry_weight);
                character.Status.Add("CurrentCarryWeight", (int)data.current_carry_weight);

                foreach (var language in data.languages)
                {
                    Language languageDatabase = new LanguageDataAccess().FindOne <Language>((int)language.id);
                    languageDatabase.Level = language.level;
                    character.Languages.Add(languageDatabase);
                }
                foreach (var skill in data.skills)
                {
                    Skill skillDatabase = new SkillDataAccess().FindOne <Skill>((int)skill.id);
                    skillDatabase.Level = skill.level;
                    character.Skills.Add(skillDatabase);
                }
                foreach (var advantage in data.advantages)
                {
                    Advantage advantageDatabase = new AdvantageDataAccess().FindOne <Advantage>((int)advantage.id);
                    advantageDatabase.Level = advantage.level;
                    character.Advantages.Add(advantageDatabase);
                }
                foreach (var disadvantage in data.disadvantages)
                {
                    Disadvantage disadvantageDatabase = new DisadvantageDataAccess().FindOne <Disadvantage>((int)disadvantage.id);
                    disadvantageDatabase.Level = disadvantage.level;
                    character.Disadvantages.Add(disadvantageDatabase);
                }
                new CharacterDataAccess().InsertOne <Character>(character);
            }
            catch
            {
                return(false);
            }
            return(true);
        }