public async Task RemoveUser(string userName) { var user = await _crmDbContext.User.FirstOrDefaultAsync(f => f.Account == userName); if (user == null) { return; } _crmDbContext.Remove(user); _crmDbContext.SaveChanges(); }
private async Task <ResultCrmDb> FullRemoveModel <TModel>(int modelId, DbSet <TModel> models) where TModel : BaseModel { var result = new ResultCrmDb(); try { var model = await models.FirstOrDefaultAsync(f => f.Id == modelId); if (model == null) { return(result); } _reportDbContext.Remove(model); await _reportDbContext.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); result.AddError(ErrorCode.NoCode.ToString(), e.Message); } return(result); }