Ejemplo n.º 1
0
        public async Task AddGift(string uid, string fchar, string sid)
        {
            try
            {
                var user = await usermngr.GetUserbyId(uid);



                if (fchar != null && user != null && sid != null)
                {
                    if (fchar != null)
                    {
                        var exchar = await this.ExistGift(uid, fchar, sid);

                        if (exchar == null)
                        {
                            GiftHistory gift = new GiftHistory();
                            gift.GiftedAt = DateTime.Now;
                            gift.ServerId = sid;
                            gift.Year     = gift.GiftedAt.Year;

                            gift.CharacterName = fchar;
                            gift.uId           = user.Id;
                            db.GiftHistory.Add(gift);
                            await db.SaveChangesAsync();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);
            }
        }
Ejemplo n.º 2
0
        protected override void Seed(AZBContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            FavoriteCharacter fav = new FavoriteCharacter();

            fav.AddedAt       = DateTime.Now;
            fav.CharacterName = "test";
            fav.ServerId      = "test";
            fav.uId           = "test";
            context.FavoriteCharacters.AddOrUpdate(fav);
            GiftHistory gift = new GiftHistory();

            gift.ServerId      = "test";
            gift.uId           = "test";
            gift.Year          = 1;
            gift.GiftedAt      = DateTime.Now;
            gift.CharacterName = "test";
            context.GiftHistory.AddOrUpdate(gift);
            context.SaveChanges();
        }
Ejemplo n.º 3
0
        public async Task <GiftHistory> GetUsersGiftById(string uid, int id)
        {
            try
            {
                GiftHistory ap = null;

                var chars = await this.GetUserGift(uid);

                if (chars != null)
                {
                    ap = chars.Find(x => x.Id == id);
                }



                return(ap);
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);
                return(null);
            }
        }