public void Save(TypeCoin Typecoin) { using (var context = _IFactoryContext.Create()) { string sqlquery = "insert into TypeCoins(Name,Tag) values(@Name,@Tag)"; context.Database.ExecuteSqlCommand(sqlquery , new SqlParameter("Name", Typecoin.Name) , new SqlParameter("Tag", Typecoin.Tag)); context.SaveChanges(); } }
public ActionResult Create(int?id) { Stream req = Request.InputStream; req.Seek(0, System.IO.SeekOrigin.Begin); string json = new StreamReader(req).ReadToEnd(); TypeCoin typecoint = JsonConvert.DeserializeObject <TypeCoin>(json); _ITypeCoinServices.Save(typecoint); return(Json("OK")); }
public async Task RemoveCoinAsync(Guid userId, TypeCoin typeCoin) { var purse = await FirstOrDefaultAsync(x => x.ApplicationUserId == userId, include : sourse => sourse.Include(m => m.PurseCoins)); PurseCoin findCoins = purse.PurseCoins.FirstOrDefault(x => x.TypeCoin == typeCoin); if (findCoins == null || findCoins.Count == 0) { throw new ApplicationException("This coin is not found"); } findCoins.Count--; await Update(purse); }
public Coin(TypeCoin typeCoin) { TypeCoin = typeCoin; }
public async Task AddCoinAsync(Guid userId, TypeCoin typeCoin) { await AddCoinsAsync(userId, new List <Coin> { new Coin(typeCoin) }); }
public void Save(TypeCoin Typecoin) { _ITypeCoinRepository.Save(Typecoin); }
public async Task AddCoinAsync(TypeCoin typeCoin) { var vmUser = await _userManager.FindByNameAsync(VMUSERNAME); await _purseRepository.AddCoinAsync(vmUser.Id, typeCoin); }
public async Task AddCoinAsync(TypeCoin typeCoin) { var vmUser = await _context.Users.FirstOrDefaultAsync(x => x.UserName == VMUSERNAME); await _purseRepository.AddCoinAsync(vmUser.Id, typeCoin); }