예제 #1
0
        public virtual TypeBLL GetTypeBLLByName(string name)
        {
            TypeBLL type    = new TypeBLL();
            TypeDAL typeDal = uow.Types.GetOne(o => o.NameType == name);

            if (typeDal != null)
            {
                type.Id        = typeDal.Id;
                type.MaxLength = typeDal.MaxLength;
                type.MinLength = typeDal.MinLength;

                typeDal.Attributes = uow.StrAttribure.Get(o => o.TypeDALId == typeDal.Id);
                typeDal.Required   = uow.StringRequired.Get(o => o.TypeDALId == typeDal.Id);
                List <string> Att = new List <string>();
                List <string> Req = new List <string>();
                foreach (var g in typeDal.Attributes)
                {
                    Att.Add(g.Attribute);
                }
                foreach (var g in typeDal.Required)
                {
                    Req.Add(g.Required);
                }
                type.Required   = Req;
                type.Attributes = Att;
                return(type);
            }
            else
            {
                throw new TypeNotFoundException(string.Format("Type \"{0}\" not found.", name));
            }
        }
예제 #2
0
        public List <TypeBO> getListSearch()
        {
            if (TypeDAL.getList().Count == 0)
            {
                TypeDAL.LoadData();
            }

            return(TypeDAL.getListSearch());
        }
        public ActionResult post_dex(pokedexpost poke, IEnumerable <HttpPostedFileBase> image)
        {
            pokedex pokedata = Newtonsoft.Json.JsonConvert.DeserializeObject <pokedex>(poke.dexdata);
            stat    statdata = Newtonsoft.Json.JsonConvert.DeserializeObject <stat>(poke.statdata);
            var     type     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <type> >(poke.typedata);

            type[]         tipe   = type.ToArray();
            pokemon_type[] poktip = new pokemon_type[tipe.Count()];
            using (TypeDAL tipedal = new TypeDAL())
            {
                for (int i = 0; i < tipe.Count(); i++)
                {
                    poktip[i]            = new pokemon_type();
                    poktip[i].type_id    = tipedal.get_type_id(tipe[i].type1);
                    poktip[i].pokedex_id = pokedata.pokedex_id;
                }
            }
            statdata.pokedex_id = pokedata.pokedex_id;


            //simpan file ke folder, belum insert string ke database
            string filepath = "";

            if (image.Count() > 0)
            {
                foreach (var pic in image)
                {
                    if (pic != null)
                    {
                        filepath = Path.Combine(HttpContext.Server.MapPath("~/Content/Images"), pic.FileName);
                        pic.SaveAs(filepath);
                        pokedata.image = pic.FileName;
                    }
                }
            }

            using (PokedexDAL pokedal = new PokedexDAL())
            {
                string[] respon = pokedal.addpokedex(pokedata, statdata, poktip);
                Respon   res    = new Respon();
                if (respon[0] == "1")
                {
                    res.error   = "0";
                    res.success = "1";
                    res.tag     = "post pokedex";
                    res.token   = "success adding";
                }
                else
                {
                    res.error   = "1";
                    res.success = "0";
                    res.tag     = "post pokedex";
                    res.token   = "failed adding";
                }
                return(Json(res));
            }
        }
예제 #4
0
        public IHttpActionResult get_type()
        {
            using (TypeDAL type = new TypeDAL())
            {
                var        list      = type.get_type().ToList();
                typejson[] pokemodel = new typejson[list.Count()];

                for (int i = 0; i < list.Count; i++)
                {
                    pokemodel[i]           = new typejson();
                    pokemodel[i].type_name = list[i].type1;
                }
                return(Json(pokemodel));
            }
        }
예제 #5
0
 public virtual bool ChangeType(TypeBLL New)
 {
     if (uow.Types.GetOne(o => o.Id == New.Id) != null)
     {
         TypeDAL type = Check(New);
         uow.Types.Remove(uow.Types.GetOne(o => o.Id == New.Id));
         uow.Save();
         uow.Types.Create(type);
         uow.Save();
         return(true);
     }
     else
     {
         throw new TypeNotFoundException(string.Format("Type with this \"{0}\" ID not Found.", New.Id));
     }
 }
예제 #6
0
        public IHttpActionResult get_pokedex()
        {
            using (PokedexDAL poke = new PokedexDAL())
            {
                var           list      = poke.get_pokedex().ToList();
                pokedexjson[] pokemodel = new pokedexjson[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    pokemodel[i]              = new pokedexjson();
                    pokemodel[i].pokedex_id   = list[i].pokedex_id;
                    pokemodel[i].pokemon_name = list[i].pokemon_name;
                    pokemodel[i].species      = list[i].species;
                    pokemodel[i].height       = list[i].height;
                    pokemodel[i].weight       = list[i].weight;
                    pokemodel[i].abilities    = list[i].abilities;
                    pokemodel[i].image        = list[i].image;
                    pokemodel[i].req_move     = list[i].req_move;

                    var      type = list[i].pokemon_type.ToArray();
                    string[] tipe = new string[type.Count()];
                    using (TypeDAL typedal = new TypeDAL())
                    {
                        for (int u = 0; u < type.Count(); u++)
                        {
                            tipe[u] = typedal.get_type_name(type[u].type_id);
                        }
                    }
                    pokemodel[i].type = tipe;

                    var  stat      = list[i].stats.ToArray();
                    stat statmodel = new stat();
                    for (int o = 0; o < stat.Count(); o++)
                    {
                        statmodel            = new stat();
                        statmodel.pokedex_id = list[i].pokedex_id;
                        statmodel.hp         = stat[o].hp;
                        statmodel.attack     = stat[o].attack;
                        statmodel.defense    = stat[o].defense;
                        statmodel.spattack   = stat[o].spattack;
                        statmodel.spdefense  = stat[o].spdefense;
                        statmodel.speed      = stat[o].speed;
                    }
                    pokemodel[i].stat = statmodel;
                }
                return(Json(pokemodel));
            }
        }
예제 #7
0
        public IHttpActionResult get_move()
        {
            using (MoveDAL movedal = new MoveDAL())
            {
                try
                {
                    var        list     = movedal.get_move().ToList();
                    movejson[] movedata = new movejson[list.Count()];

                    for (int i = 0; i < list.Count(); i++)
                    {
                        movedata[i]           = new movejson();
                        movedata[i].move_id   = list[i].move_id;
                        movedata[i].move_name = list[i].move_name;
                        using (TypeDAL type = new TypeDAL())
                        {
                            movedata[i].move_type = type.get_type_name(list[i].move_type);
                        }
                        movedata[i].move_category = list[i].move_category;
                        movedata[i].move_damage   = list[i].move_damage;
                        movedata[i].move_effect   = list[i].move_effect;
                    }
                    return(Json(movedata));
                }
                catch (Exception x)
                {
                    Respon respon = new Respon();
                    respon.success = "0";
                    respon.error   = "1";
                    respon.tag     = "get move";
                    respon.token   = x.Message;

                    return(Json(respon));
                }
            }
        }
예제 #8
0
 /// <summary>
 /// 删除类型
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool DeleteType(int id)
 {
     return(TypeDAL.DeleteType(id));
 }
예제 #9
0
 /// <summary>
 /// 模糊查询类型名
 /// </summary>
 /// <param name="TypeName"></param>
 /// <returns></returns>
 public static DataTable GetDataTableLikeTypeName(string TypeName)
 {
     return(TypeDAL.GetDataTableLikeTypeName(TypeName));
 }
예제 #10
0
 /// <summary>
 /// 添加类型
 /// </summary>
 /// <param name="TypeName"></param>
 /// <returns></returns>
 public static bool InsertType(string TypeName)
 {
     return(TypeDAL.InsertType(TypeName));
 }
예제 #11
0
 /// <summary>
 /// 修改类型名根据类型编号
 /// </summary>
 /// <param name="TypeID"></param>
 /// <param name="TypeName"></param>
 /// <returns></returns>
 public static bool UpdateType(int TypeID, string TypeName)
 {
     return(TypeDAL.UpdateType(TypeID, TypeName));
 }
예제 #12
0
 /// <summary>
 /// 查询类型
 /// </summary>
 /// <returns></returns>
 public static DataTable selecttype()
 {
     return(TypeDAL.selecttype());
 }
예제 #13
0
 /// <summary>
 /// 根据类型名返回类型编号
 /// </summary>
 /// <param name="TypeName">类型名</param>
 /// <returns>TypeId</returns>
 public static int GetTypeIDByTypeName(string TypeName)
 {
     return(TypeDAL.GetTypeIDByTypeName(TypeName));
 }
예제 #14
0
        private TypeDAL Check(TypeBLL value)
        {
            TypeDAL type = new TypeDAL();
            List <StringRequired>  Req = new List <StringRequired>();
            List <StringAttribute> Att = new List <StringAttribute>();

            if (value.Required != null)
            {
                foreach (var t in value.Required)
                {
                    if (!value.Attributes.Contains(t))
                    {
                        throw new IncorrectTypingException(string.Format("Attribute \"{0}\" not found", t));
                    }

                    Req.Add(new StringRequired()
                    {
                        Required = t, TypeDALId = value.Id
                    });
                }
            }
            if (value.Attributes != null)
            {
                foreach (var t in value.Attributes)
                {
                    Att.Add(new StringAttribute()
                    {
                        Attribute = t, TypeDALId = value.Id
                    });
                }
            }
            if (value.MaxLength.Count != 0)
            {
                foreach (var t in value.MaxLength)
                {
                    if (!value.Attributes.Contains(t.Key))
                    {
                        throw new IncorrectTypingException(string.Format("Attribute \"{0}\" not found", t.Key));
                    }

                    if (value.MinLength.ContainsKey(t.Key))
                    {
                        if (int.Parse(value.MinLength[t.Key]) >= int.Parse(t.Value))
                        {
                            throw new IncorrectTypingException(string.Format("Min value > Max value. In this \"{0}\" attribute", t.Key));
                        }
                    }
                }
            }
            if (value.MinLength.Count != 0)
            {
                foreach (var t in value.MinLength)
                {
                    if (!value.Attributes.Contains(t.Key))
                    {
                        throw new IncorrectTypingException(string.Format("Attribute \"{0}\" not found", t.Key));
                    }
                }
            }
            type.Required   = Req;
            type.NameType   = value.NameType.ToLower();
            type.MaxLength  = value.MaxLength;
            type.MinLength  = value.MinLength;
            type.Attributes = Att;
            return(type);
        }
예제 #15
0
파일: TypeBLL.cs 프로젝트: abigabaw/wis
        /// <summary>
        /// To Get Land Type
        /// </summary>
        /// <returns></returns>
        public TypeList GetLandType()
        {
            TypeDAL objTypeDAL = new TypeDAL();

            return(objTypeDAL.GetLandType());
        }
예제 #16
0
 public bool Insert(TypeBO type)
 {
     return(TypeDAL.Insert(type));
 }
예제 #17
0
 public bool Delete(TypeBO type)
 {
     return(TypeDAL.Delete(type));
 }
예제 #18
0
 public bool Edit(TypeBO type)
 {
     return(TypeDAL.Edit(type));
 }