コード例 #1
0
        public ChampionDto CreateChampion(ChampionDto champ)
        {
            var champTemp = Mapper.Map <Champion>(champ);
            var result    = _champRepositories.Create(champTemp);

            if (_champRepositories.SaveChanges() > 0)
            {
                return(Mapper.Map <ChampionDto>(result));
            }

            return(null);
        }
コード例 #2
0
        public UserDto Create(UserDto entity)
        {
            var user = Mapper.Map <User>(entity);

            _userRepositories.Create(user);
            _userRepositories.SaveChanges();
            return(entity);
        }
コード例 #3
0
ファイル: BaseController.cs プロジェクト: imantama/NetCore
        public async Task <ActionResult <TEntity> > Post(TEntity entity)
        {
            var data = await _repo.Create(entity);

            if (data > 0)
            {
                return(Ok("mantap"));
            }
            return(BadRequest("Create UnSuccesfull"));
        }
コード例 #4
0
        public RankDto Create(RankDto data)
        {
            var rank = Mapper.Map <Rank>(data);

            var result = _repoRank.Create(rank);

            if (_repoRank.SaveChanges() > 0)
            {
                return(Mapper.Map <RankDto>(result));
            }
            return(null);
        }
コード例 #5
0
        public SkinDto CreateSkin(SkinDto skin)
        {
            var skinTemp = Mapper.Map <Skin>(skin);
            var result   = _skinRepositories.Create(skinTemp);

            if (_skinRepositories.SaveChanges() > 0)
            {
                return(Mapper.Map <SkinDto>(result));
            }

            return(null);
        }
コード例 #6
0
        public PageGemDto CreatePageGem(PageGemDto data)
        {
            var pg = Mapper.Map <PageGem>(data);

            _pageGemRepositories.Create(pg);

            if (_pageGemRepositories.SaveChanges() > 0)
            {
                return(data);
            }
            return(null);
        }
コード例 #7
0
        public UserRechargeHistoryDto Create(UserRechargeHistoryDto rechargeHistory)
        {
            var data = Mapper.Map <UserRechargeHistory>(rechargeHistory);

            var result = _rechargeRepositories.Create(data);

            if (_rechargeRepositories.SaveChanges() > 0)
            {
                return(Mapper.Map <UserRechargeHistoryDto>(result));
            }

            return(null);
        }
コード例 #8
0
        public LuckyWheelHistoryDto CreateLuckyHistory(LuckyWheelHistoryDto data)
        {
            var entity = Mapper.Map <LuckyWheelHistory>(data);

            entity.CreatedDate = DateTime.Now;
            entity.UserId      = data.UserId;

            var result = _luckyWheelHistoryRepositories.Create(entity);

            if (_luckyWheelHistoryRepositories.SaveChanges() > 0)
            {
                return(Mapper.Map <LuckyWheelHistoryDto>(result));
            }

            return(null);
        }
コード例 #9
0
        public LuckyWheelItemDto CreateLuckyItem(LuckyWheelItemDto data)
        {
            var entity = Mapper.Map <LuckyWheelItem>(data);

            entity.CreatedDate = DateTime.Now;
            entity.ImageUrl    = "../Images/LuckyItem/" + FileUlti.SaveFile(data.FileImage, data.ImageUrl);

            var result = _luckyWheelItemRepositories.Create(entity);

            if (_luckyWheelItemRepositories.SaveChanges() > 0)
            {
                return(Mapper.Map <LuckyWheelItemDto>(result));
            }

            return(null);
        }
コード例 #10
0
        public UserTradingHistoryDto Create(UserTradingHistoryDto tradingHistory)
        {
            var data    = Mapper.Map <UserTradingHistory>(tradingHistory);
            var existed = _tradingHistory.Read(a => a.AccountId == data.AccountId).Any();

            if (existed)
            {
                _tradingHistory.Delete(a => a.AccountId == data.AccountId);
            }

            var result = _tradingHistory.Create(data);

            if (_tradingHistory.SaveChanges() > 0)
            {
                return(Mapper.Map <UserTradingHistoryDto>(result));
            }
            return(null);
        }
コード例 #11
0
        public AccountDto Create(AccountDto entity, string champ, string skin)
        {
            var account = Mapper.Map <Account>(entity);

            var result = _repoAccount.Create(account);

            if (_repoAccount.SaveChanges() > 0)
            {
                var accountAdded = _repoAccount.ReadOne(a => a.Id == result.Id);

                accountAdded.Champions = ChampionForCreation(champ);
                accountAdded.Skins     = SkinForCreation(skin);

                _repoAccount.SaveChanges();
                return(Mapper.Map <AccountDto>(result));
            }

            return(null);
        }