Exemplo n.º 1
0
        /// <summary>
        /// 设置生肖
        /// </summary>
        public void Set_Animal(Globe_Clue item, List <Animal_Info> Animal_Info_List, List <Globe> GlobeList)
        {
            try
            {
                string[] globe_clues = item.Clue.Split(new char[] { ',' });
                string[] globe_pays  = item.Pay.Split(new char[] { ',' });
                for (int i = 0; i < globe_clues.Length; i++)
                {
                    int         clue        = Convert.ToInt32(globe_clues[i]);
                    Animal_Info animal_Info = Animal_Info_List.FirstOrDefault(g => g.Code == clue);
                    if (animal_Info != null)
                    {
                        float         pay          = float.Parse(globe_pays[i]);
                        Animal_Info_S Animal_InfoS = Animal_Info_S.GetBase(animal_Info, pay);

                        List <Globe_S> templist = new List <Globe_S>();
                        foreach (var code in Animal_InfoS.GlobeCodeList)
                        {
                            Globe globle = GlobeList.FirstOrDefault(c => c.Code == code);
                            if (globle != null)
                            {
                                Globe_S globle_s = Globe_S.GetBase(globle);
                                templist.Add(globle_s);
                            }
                        }
                        Animal_InfoS.GlobeList = templist.ToArray();
                        this.Animal_List.Add(Animal_InfoS);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }
Exemplo n.º 2
0
        public static List <Animal_Info_S> GetBase(string globes, List <Animal_Info> Item_List, string pays)
        {
            List <Animal_Info_S> list = new List <Animal_Info_S>();

            try
            {
                if (!string.IsNullOrEmpty(globes) && !string.IsNullOrEmpty(pays))
                {
                    string[] globeArray = globes.Split(new char[] { ',' });
                    string[] payArray   = pays.Split(new char[] { ',' });
                    for (int i = 0; i < globeArray.Length; i++)
                    {
                        int         clue  = Convert.ToInt32(globeArray[i]);
                        decimal     pay   = Convert.ToDecimal(payArray[i]);
                        Animal_Info globe = Item_List.FirstOrDefault(g => g.Code == clue);
                        list.Add(Animal_Info_S.GetBase(globe, (float)pay));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }

            return(list);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(Animal_Info animal_Info)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _db.Animal_Info.Add(animal_Info);
            await _db.SaveChangesAsync();

            return(RedirectToPage("Index"));
        }
Exemplo n.º 4
0
        public static Animal_Info_S GetBase(Animal_Info item, float pay)
        {
            Animal_Info_S Animal_InfoS = new Animal_Info_S()
            {
                Id            = item.Id,
                Code          = item.Code,
                GlobeCodeList = Split_Hepler.str_to_ints(item.Globe),
                IsEnable      = item.IsEnable,
                Name          = item.Name,
                PayReturn     = pay,
            };

            return(Animal_InfoS);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Animal_Info = await _context.Animal_Info.FirstOrDefaultAsync(m => m.Id == id);

            if (Animal_Info == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Animal_Info = await _context.Animal_Info.FindAsync(id);

            if (Animal_Info != null)
            {
                _context.Animal_Info.Remove(Animal_Info);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 7
0
        public static string GetBase_Str(string globes, List <Animal_Info> Item_List)
        {
            string content = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(globes))
                {
                    string[] globeArray = globes.Split(new char[] { ',' });
                    for (int i = 0; i < globeArray.Length; i++)
                    {
                        int         clue  = Convert.ToInt32(globeArray[i]);
                        Animal_Info globe = Item_List.FirstOrDefault(g => g.Code == clue);
                        content += globe.Name + ",";
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }

            return(content);
        }