<pre>return await _dbContext.SaveChangesAsync() > 0;
trans.Commit()
public async Task<bool> Save(string company, int number,string registrationNumber) { using (var trans = _dbContext.Database.BeginTransaction()) { var db = new SibaCiidDbContext(); var dbSet = _dbContext.Set<IntermediaryAssignment>(); // set the database var check =await (from s in db.StickerDistributions join i in db.IntermediaryAssignment on s.CompanyCode equals i.CompanyCode where s.Dispatched == false && s.CompanyCode == company <pre>&& s.StickerCode != i.StickerCode select s).ToListAsync(); var datas = await (from s in db.StickerDistributions where s.Dispatched == false && s.CompanyCode == company && s.IntermediaryDispatched == false select s) .ToListAsync(); var data = await (from s in db.StickerDistributions where s.Dispatched == false && s.CompanyCode == company && s.IntermediaryDispatched == false select s).Take(number).ToListAsync(); var intermediary = (await _repo.FindBy(s => s.RegistrationNumber == registrationNumber && s.Status == EntityStatus.Active)).FirstOrDefault(); foreach (var sticker in data) { if (dbSet.Any(s => s.StickerCode != sticker.StickerCode)) { var entity = new IntermediaryAssignment(); entity.CompanyCode = sticker.CompanyCode; entity.StickerCode = sticker.StickerCode; entity.RegistrationNumber = intermediary.RegistrationNumber; entity.Status = EntityStatus.Active; entity.CreatedDate = DateTime.Now; entity.Dispatched = false; entity.IntermediaryType = intermediary.IntermediaryType; // entity.Sticker.Id = sticker.Sticker.Id; sticker.IntermediaryDispatched = true; dbSet.Add(entity); } } return await _dbContext.SaveChangesAsync() > 0; trans.Commit(); } }
return
var result = await _dbContext.SaveChangesAsync(); trans.Commit(); if(result > 0) return true; return false;
Task results = _dbContext.SaveChangesAsync() ; trans.Commit(); return true ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)