how to update a table in sqlite corresponding to a id - xamarin

i have 2 forms. first form saves value to company_master except 2 fields.In second form want to update company_master in sqlite when id=1 those 2 fileds.
in form2 i have tried simple update but it doesnot work
form1.xaml
private async void OnSave(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(ECompnyPhone.Text))
{
}
else
{
if (pickCompnyType.SelectedIndex == 0)
{
type = "Academic";
}
else if (pickCompnyType.SelectedIndex == 1)
{
type = "Financial";
}
if (pickYear.SelectedIndex == 0)
{
year = "April - March";
}
else if (pickYear.SelectedIndex == 1)
{
year = "January - December";
}
var cmpny = new COMPANY_MASTER
{
Name = ECompnyName.Text,
PhoneNo = ECompnyPhone.Text,
Email = ECompnyEmail.Text,
Address1 = ECompnyAdd1.Text,
Address2 = ECompnyAdd2.Text,
Address3 = ECompnyAdd3.Text,
Type = type,
Wing = EWing.Text,
Year = year
};
var checker = await _connection.InsertAsync(cmpny);
if (checker == 1)
{
await DisplayAlert("Message", "Data saved successfully.", "Ok");
await Navigation.PopAsync();
}
}
}
catch
{
await DisplayAlert("Error", "Error in data saving. Please retry later.", "Ok");
}
}
form2.xaml
private async void OnSave(object sender, EventArgs e)
{
try
{
var expense = new COMPANY_MASTER
{
Opening_Cash = Convert.ToDecimal(EOCash.Text),
Available_Cash = Convert.ToDecimal(EACash.Text)
};
var checker = await _connection.UpdateAsync(expense);
if (checker == 1)
{
await DisplayAlert("Message", "Data saved successfully.", "Ok");
await Navigation.PopAsync();
}
}
catch
{
await DisplayAlert("Error", "Error in data saving. Please retry later.", "Ok");
}
}
Company_master.cs
public class COMPANY_MASTER : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
[PrimaryKey, AutoIncrement]
public int CompanyId { get; set; }
public string _name { get; set; }
public string _address1 { get; set; }
public string _address2 { get; set; }
public string _address3 { get; set; }
public string _email { get; set; }
public string _phoneNo { get; set; }
public string _type { get; set; }
public string _wing { get; set; }
public string _year { get; set; }
public decimal _openingcash { get; set; }
public decimal _availablecash { get; set; }
public decimal Available_Cash
{
get { return _availablecash; }
set
{
if (_availablecash == value)
return;
_availablecash = value;
OnPropertyChanged();
}
}
public decimal Opening_Cash
{
get { return _openingcash; }
set
{
if (_openingcash == value)
return;
_openingcash = value;
OnPropertyChanged();
}
}
public string Name
{
get { return _name; }
set
{
if (_name == value)
return;
_name = value;
OnPropertyChanged();
}
}
public string Year
{
get { return _year; }
set
{
if (_year == value)
return;
_year = value;
OnPropertyChanged();
}
}
public string Wing
{
get { return _wing; }
set
{
if (_wing == value)
return;
_wing = value;
OnPropertyChanged();
}
}
public string Type
{
get { return _type; }
set
{
if (_type == value)
return;
_type = value;
OnPropertyChanged();
}
}
public string PhoneNo
{
get { return _phoneNo; }
set
{
if (_phoneNo == value)
return;
_phoneNo = value;
OnPropertyChanged();
}
}
public string Address1
{
get { return _address1; }
set
{
if (_address1 == value)
return;
_address1 = value;
OnPropertyChanged();
}
}
public string Address2
{
get { return _address2; }
set
{
if (_address2 == value)
return;
_address2 = value;
OnPropertyChanged();
}
}
public string Address3
{
get { return _address3; }
set
{
if (_address3 == value)
return;
_address3 = value;
OnPropertyChanged();
}
}
public string Email
{
get { return _email; }
set
{
if (_email == value)
return;
_email = value;
OnPropertyChanged();
}
}
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
i want to update company_master's opening_cash and available_cash where companyid=1 in form2
now updation is not working

You can't update a new element
var expense = new COMPANY_MASTER
{
Opening_Cash = Convert.ToDecimal(EOCash.Text),
Available_Cash = Convert.ToDecimal(EACash.Text)
};
var checker = await _connection.UpdateAsync(expense); //here expense.companyid = 0
...
when you create a new object id is asigned with 0 value, for update id must exist in your table.

Related

How insert multiple value in Intermediate table through API

I use to add value from the VUEJS where write code like this.
<multiselect v-model="schoolTypeform.schoolTypeId" :options="SchoolTypes" :multiple="true" :close-on-select="false" :clear-on-select="false" :preserve-search="true" placeholder="Pick School Type" label="name" track-by="name" :preselect-first="true">
and the JS code for this is written like this:
async addSchool() {
this.isbtnLoading = true;
this.isException = false;
await this.axios.post(this.school, this.form).then(response => {
this.addSchoolType(response.data);
})
},
async addSchoolType(id) {
this.isbtnLoading = true;
this.isException = false;
this.schoolTypeform.shoolId = id;
await this.axios.post(this.apiBasedUrl + '/SchoolsSchoolType', this.schoolTypeform).then(response => {
this.isbtnLoading = false;
});
Now my ER structure is given like this:
School:(Table1)
public partial class Schools
{
public Guid ID { get; set; }
public string Name{ get; set; }
// Navigation
public ICollection<SchoolsSchoolType> SchoolsSchoolTypes { get; set; }
}
SchoolType:(Table2)
public class SchoolType
{
public Guid Id { get; set; }
public string Name { get; set; }
//Navigation
public ICollection<SchoolsSchoolType> SchoolsSchoolTypes { get; set; }
}
SchoolsSchoolType (It is Intermediate table): Here the relation between the above is many to many.
public class SchoolsSchoolType
{
public Guid Id { get; set; }
public Guid ShoolId { get; set; }
public Schools Schools { get; set; }
public Guid SchoolTypeId { get; set; }
public SchoolType SchoolType { get; set; }
}
Here is repository method write for single value input, but I want to add here multiple value in the intermediates or junction table.
public async Task<Guid> CreateSchoolsAsync(SchoolsCreateVm schoolsCreateVm)
{
if (_GpsContext != null)
{
var schoolsEntity = new Schools()
{
ID = Guid.NewGuid(),
Name = schoolsCreateVm.Name,
SchoolsSchoolTypes = new List<SchoolsSchoolType>()
};
var schoolType = new SchoolType();
schoolsEntity.SchoolsSchoolTypes = new List<SchoolsSchoolType>
{
new SchoolsSchoolType
{
ShoolId =schoolsEntity.ID,
SchoolTypeId =schoolType.Id
}
};
return schoolsEntity.ID;
}
return Guid.Empty
}
Controller code is written here:
[HttpPost]
public async Task<IActionResult> PostSchool([FromBody]SchoolsCreateVm schoolsCreateVm)
{
var result = await _schoolsRepository.CreateSchoolsAsync(schoolsCreateVm);
if (result != null)
{
return Ok(result);
}
return NotFound();
}
Here is viewmodel used by me:
public class SchoolsCreateVm
{
public string Name { get; set; }
public List<Guid> SchoolTypeId{ get; set; } // List type of for intermediate table
public SchoolsCreateVm()
{
SchoolTypeId = new List<Guid>();
}
How can insert many schooltype for a single school in the intermediates(many to many) relation table through the VUEJS multiple selects.
Finally I am able to find the solution...
public async Task<Guid> CreateSchoolsAsync(SchoolsCreateVm schoolsCreateVm)
{
if (_GpsContext != null)
{
var schoolId = Guid.NewGuid();
var schoolsEntity = new Schools()
{
ID = schoolId, // 1--[1,2,3]
Name = schoolsCreateVm.Name,
};
// Here the code in which we can enter in the multiple table and Intermediate table
var SchoolsSchoolTypeList = new List<SchoolsSchoolType>();
foreach(var item in schoolsCreateVm.SchoolTypeId)
{
SchoolsSchoolTypeList.Add(new SchoolsSchoolType
{
Id = Guid.NewGuid(),
ShoolId = schoolId,
SchoolTypeId = item,
});
}
await _GpsContext.School.AddAsync(schoolsEntity);
_GpsContext.SchoolsSchoolTypes.AddRange(SchoolsSchoolTypeList);//Enter here for intermediate table that is 'SchoolsSchoolTypes'
await _GpsContext.SaveChangesAsync();
return schoolsEntity.ID;
}
return Guid.Empty;
}

How to trigger App Center Push from my asp.net Web API?

I'm making an android Xamarin.Android. I finished the android application and now I want to add remote push notifications based on my item condition in my database that can accessed from ASP.Net Web Api.
I succeeded sent notifications from App Center Push to my application. I already authorized the App Center Client and now can access the app center api. I'm planning to merge the app center api to my asp.net web api if possible. But I don't know where to start it.
Should I put the app center action to my controller (I don't know if its working or not) or there's another way?
here's my controller:
public class InventoriesController : ApiController
{
private InventoryRepository _inventoryRepository;
public InventoriesController()
{
_inventoryRepository = new InventoryRepository();
}
// GET: api/Categories
public IHttpActionResult GetInventories()
{
IEnumerable<InventoryViewModel> inv = _inventoryRepository.GetAll().ToList().Select(e=> new InventoryViewModel(e)).ToList();
return Ok(inv);
}
// GET: api/Categories/5
[ResponseType(typeof(InventoryViewModel))]
public IHttpActionResult GetInventory(Guid id)
{
InventoryViewModel inventory = new InventoryViewModel (_inventoryRepository.GetSingle(e => e.Id == id));
if (inventory == null)
{
return NotFound();
}
return Ok(inventory);
}
// PUT: api/Categories/5
[ResponseType(typeof(void))]
public IHttpActionResult PutInventory(Guid id, InventoryViewModel inventory)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != inventory.Id)
{
return BadRequest();
}
try
{
_inventoryRepository.Edit(inventory.ToModel());
}
catch (DbUpdateConcurrencyException)
{
if (!InventoryExist(id))
{
return NotFound();
}
else
{
throw;
}
}
return StatusCode(HttpStatusCode.NoContent);
}
// POST: api/Categories
[ResponseType(typeof(InventoryViewModel))]
public IHttpActionResult PostInventory(InventoryViewModel inventory)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
_inventoryRepository.Add(inventory.ToModel());
}
catch (DbUpdateException)
{
if (InventoryExist(inventory.Id))
{
return Conflict();
}
else
{
throw;
}
}
return CreatedAtRoute("DefaultApi", new { id = inventory.Id }, inventory);
}
// DELETE: api/Categories/5
[ResponseType(typeof(Inventory))]
public async Task<IHttpActionResult> DeleteInventory(Guid id)
{
Inventory inventory = _inventoryRepository.GetSingle(e => e.Id == id);
if (inventory == null)
{
return NotFound();
}
await _inventoryRepository.DeleteAsync(inventory);
return Ok(inventory);
}
private bool InventoryExist(Guid id)
{
IQueryable<Inventory> inv = _inventoryRepository.GetAll();
return inv.Count(e => e.Id == id) > 0;
}
And this is my model:
public class InventoryViewModel
{
public Guid Id { get; set; }
public int Quantity { get; set; }
public DateTime ExpirationDate { get; set; }
public bool IsDeleted { get; set; }
public bool IsConsumed { get; set; }
public decimal Price { get; set; }
public string ItemName { get; set; }
public Guid ProductId { get; set; }
public Guid StorageId { get; set; }
public string AddedUserId { get; set; }
public Inventory ToModel()
{
return new Inventory
{
Id = (Id == Guid.Empty) ? Guid.NewGuid() : Id,
ExpirationDate = ExpirationDate,
Price = Price,
ProductId=ProductId,
StorageId=StorageId,
ItemName=ItemName,
IsDeleted=IsDeleted,
IsConsumed=IsConsumed,
AddedUserId = AddedUserId,
};
}
public InventoryViewModel()
{
}
public InventoryViewModel(Inventory i)
{
this.Id = i.Id;
this.ExpirationDate = i.ExpirationDate;
this.Price = i.Price;
this.ProductId = i.ProductId;
this.StorageId = i.StorageId;
this.ItemName = i.ItemName;
this.AddedUserId = i.AddedUserId;
}
}
I want to make the app center send notification based on Expired Date on my Inventories model and AddedUserId. So its my web self made web api who send the notification to my apps.
I read this documentation: [https://learn.microsoft.com/en-us/appcenter/push/pushapi][1] but still don't know where I have to write in my Web Api.
Hope someone here can help me.
Thanks in advance :)
You can find detail here in appcenter REST API documentation
https://learn.microsoft.com/en-us/appcenter/push/rest-api
Appcenter REST API swagger: https://openapi.appcenter.ms/

Troubleshoot object reference error when filling mvc models with datareader?

I am using MVC 3 and I am using a datareader to create a list of items that have subItems. When I add the subitem I get "Object reference not set to an instance of an object." With the following code:
QuestionaireLine question = new QuestionaireLine();
question.Question_ID = Convert.ToInt32(reader["Question_ID"]);
question.Question_Answer = reader["Question_Answer"].ToString();
...etc..
currentGroup.Lines.Add(question); //exception thrown here
The models:
public class Questionaire
{
public int Question_Group_Id { get; set; }
public string Question_Group_Name { get; set; }
public int Question_Group_Indent { get; set; }
public int Question_Group_Order { get; set; }
public List<QuestionaireLine> Lines { get; set; }
}
public class QuestionaireLine
{
public int Question_ID { get; set; }
public string Question_Label { get; set; }
public string Question_Answer { get; set; }
public int Data_Type { get; set; }
public int Control_Type { get; set; }
public string Data_Choices { get; set; }
public int Data_Max_Length { get; set; }
public bool Issue_Tagged { get; set; }
public int Question_Order { get; set; }
public string NumberedQuestion
{
get { return String.Format("{0}. {1}", Question_Order, Question_Label); }
}
}
The whole code:
// what am I missing??
using (var conn = new SqlConnection(_connectionString))
{
List<Questionaire> groups = new List<Questionaire>();
var com = new SqlCommand();
com.Connection = conn;
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter
{
ParameterName = "#Review_ID",
Value = reviewID
});
com.CommandText = "Review_Get_Question_Groups_Answers";
conn.Open();
// Get the reader
SqlDataReader reader = com.ExecuteReader();
// Process each result in the result set
int currQuestionGroupId = 0;
Questionaire currentGroup = null;
while (reader.Read())
{
var questionGroupId = Convert.ToInt32(reader["Question_Group_Id"]);
if (questionGroupId != currQuestionGroupId)
{
currQuestionGroupId = questionGroupId;
if (currentGroup != null)
{
groups.Add(currentGroup);
}
currentGroup = new Questionaire();
currentGroup.Question_Group_Id = Convert.ToInt32(reader["Question_Group_Id"]);
currentGroup.Question_Group_Indent = Convert.ToInt32(reader["Question_Group_Indent"]);
currentGroup.Question_Group_Name = reader["Question_Group_Name"].ToString();
currentGroup.Question_Group_Order = Convert.ToInt32(reader["Question_Group_Order"]);
}
if (reader["Question_ID"] != DBNull.Value)
{
QuestionaireLine question = new QuestionaireLine();
question.Question_ID = Convert.ToInt32(reader["Question_ID"]);
question.Question_Answer = reader["Question_Answer"].ToString();
question.Issue_Tagged = Convert.ToBoolean(reader["Issue_Tagged"]);
question.Data_Type = Convert.ToInt32(reader["Data_Type"]);
question.Data_Max_Length = Convert.ToInt32(reader["Data_Max_Length"]);
question.Data_Choices = reader["Data_Choices"].ToString();
question.Question_Label = reader["Question_Label"].ToString();
question.Question_Order = Convert.ToInt32(reader["Question_Order"]);
question.Control_Type = Convert.ToInt32(reader["Control_Type"]);
currentGroup.Lines.Add(question);
}
if (currentGroup != null)
{
groups.Add(currentGroup);
}
}
reader.Close();
com.Dispose();
return groups;
}
Your Lines property on your Questionaire instance is Null. Change to:
public class Questionaire
{
public int Question_Group_Id { get; set; }
public string Question_Group_Name { get; set; }
public int Question_Group_Indent { get; set; }
public int Question_Group_Order { get; set; }
public List<QuestionaireLine> Lines { get; set; }
public Questionaire() {
Lines = new List<QuestionaireLine>();
}
b.t.w. stepping through your code would have shown you that.

knockoutjs with mvc collection model binding

I'm using knockoutjs to render a collection of items. After allowing the user to do some inline editing I need to post the collection back to the server. However, the collection isn't being populated on the server because I'm not using the name="[0].Blah" naming convention. Does anyone know how to either render name attributes like this using knockoutjs OR how to create a model binder that will allow me to extract the values from the ValueProvider?
You can see a screenshot of the ValueProvider during debugging below.
http://i.imgur.com/zSU5Z.png
Here is my managed ViewModel:
public class FundLevelInvestmentUploadResult
{
public string FileName { get; set; }
public IList<FundLevelInvestmentViewModel> Items { get; set; }
public int NumberOfErrors { get; set; }
public bool ShowErrorsOnly { get; set; }
public FundLevelInvestmentUploadResult()
{
Items = new List<FundLevelInvestmentViewModel>();
}
}
Here is the managed class for "Items":
public class FundLevelInvestmentViewModel
{
private string _fund;
private string _fundType;
private string _date;
private string _netOfWaivedFees;
private string _waivedFees;
private string _bcip;
private string _fxRate;
public uint RowIndex { get; set; }
public int? DealCode { get; set; }
public bool DealCodeIsValid { get; set; }
public string Fund
{
get { return _fund; }
set { _fund = GetString(value); }
}
public bool FundIsValid { get; set; }
public string FundType
{
get { return _fundType; }
set { _fundType = GetString(value); }
}
public bool FundTypeIsValid { get; set; }
public string DateOfInvestment
{
get { return _date; }
set { _date = GetString(value); }
}
public bool DateOfInvestmentIsValid { get; set; }
public string NetOfWaivedFees
{
get { return _netOfWaivedFees; }
set { _netOfWaivedFees = GetString(value); }
}
public bool NetOfWaivedFeesIsValid { get; set; }
public string WaivedFee
{
get { return _waivedFees; }
set { _waivedFees = GetString(value); }
}
public bool WaivedFeeIsValid { get; set; }
public string BCIP
{
get { return _bcip; }
set { _bcip = GetString(value); }
}
public bool BCIPIsValid { get; set; }
public string ExchangeRateToUSD
{
get { return _fxRate; }
set { _fxRate = GetString(value); }
}
public bool ExchangeRateToUSDIsValid { get; set; }
public string FileName { get; set; }
private IList<string> _errors;
public IList<string> Errors
{
get { return _errors ?? (_errors = new List<string>());}
set { _errors = value; }
}
public bool Show { get; set; }
public FundLevelInvestmentViewModel()
{
Errors = new List<string>();
Show = true;
}
// knockoutjs is returning "null" instead of "" for a null object when calling ko.mapping.fromJS
private string GetString(string value)
{
if (value == "null")
return string.Empty;
return value;
}
}
Here is my knockout viewModel:
var viewModel = {
FileData: ko.observableArray([]),
validateFile: function (file, event) {
$.ajax({
type: 'post',
url: newUrl,
data: ko.mapping.toJS(file)
}).done(function (data) {
var newFile = ko.mapping.fromJS(data);
var index = file.Items.indexOf(file);
viewModel.FileData.replace(file, newFile);
});
}
};
If you are using version 2.1.0.0 or later of knockout you can render the name attribute as follows from an observable array.
<input data-bind='attr: { name: "Items["+$index()+"].DealCode"}' />

Refactor to filtering lists using LINQ

I use several lists of similar objects. Anyone object has a List property. Basically, I need compare several lists.
I would have thought that LINQ would be an ideal way of doing this but after trying joins, extension methods, using yields, etc. I'm still having trouble.
any suggestions for refactor my code to using LINQ ?
Update: I'm refactor ContieneServidor (ContainsServer translate) method
private static bool ContieneServidorRefactoring(List<GrupoServidorDto> datosGruposServidores, string nombreMaquina)
{
var total = datosGruposServidores
.SelectMany(g => g.Servidores)
.Where(x => x.Nombre.Equals(nombreMaquina)).Count();
if (total > 0) return true;
return false;
}
My code:
var datosGruposServidores = new List<GrupoServidorDto>();
var gruposCompletos = new List<GrupoServidorSeleccionado>();
var maquinasSeleccionadas = new List<string>();
...
// Comprobación de Máquinas
var maquinasNoEncontradas = new List<string>();
foreach (var g in gruposCompletos)
{
foreach (var server in g.Servidores)
{
var encontrado =
ContieneServidor(datosGruposServidores, server.Nombre);
if (!encontrado) maquinasNoEncontradas.Add(server.Nombre);
}
}
foreach (var m in maquinasSeleccionadas)
{
var encontrado = ContieneServidor(datosGruposServidores, m);
if (!encontrado) maquinasNoEncontradas.Add(m);
}
if (maquinasNoEncontradas.Count > 0)
{
var sb = new StringBuilder();
var sep = "";
foreach (var maq in maquinasNoEncontradas)
{
sb.Append(sep + maq);
sep = ", ";
}
System.Diagnostics.Trace.WriteLine("Máquinas no encontradas: " + sb.ToString());
throw new InvalidOperationException("Máquinas no encontradas: " + sb.ToString());
}
}
private static bool ContieneServidor(
List<GrupoServidorDto> datosGruposServidores, string nombreMaquina)
{
foreach (var g in datosGruposServidores)
{
var servidor = g.Servidores.Where(s => s.Nombre.Equals(nombreMaquina));
if (servidor != null && servidor.Count() > 0) return true;
}
return false;
}
private static bool ContieneServidorRefactoring(List<GrupoServidorDto> datosGruposServidores, string nombreMaquina)
{
var total = datosGruposServidores
.SelectMany(g => g.Servidores)
.Where(x => x.Nombre.Equals(nombreMaquina)).Count();
if (total > 0) return true;
return false;
}
The types:
public class GrupoServidorDto
{
public int IdGrupo { get; set; }
public string Nombre { get; set; }
private List<ServidorDto> servidores = new List<ServidorDto>();
public List<ServidorDto> Servidores
{
get { return servidores; }
set { servidores = value; }
}
}
public class ServidorDto
{
public int Id { get; set; }
public string Nombre { get; set; }
public string IP { get; set; }
public string Entorno { get; set; }
public string Habilitado { get; set; }
public string Tipo { get; set; }
public int IdGrupo { get; set; }
}
[Serializable()]
public class GrupoServidorSeleccionado
{
[XmlAttribute()]
public int IdGrupo { get; set; }
[XmlAttribute()]
public string Nombre { get; set; }
private List<ServidorSeleccionado> servidores =
new List<ServidorSeleccionado>();
[XmlElement()]
public List<ServidorSeleccionado> Servidores
{
get { return servidores; }
set { servidores = value; }
}
[XmlAttribute()]
public bool EstanTodasLasMaquinasSeleccionadas { get; set; }
public GrupoServidorSeleccionado() { }
}
[Serializable()]
public class ServidorSeleccionado
{
[XmlAttribute()]
public int Id { get; set; }
[XmlAttribute()]
public string Nombre { get; set; }
[XmlAttribute()]
public string IP { get; set; }
[XmlAttribute()]
public string Entorno { get; set; }
[XmlAttribute()] // [XmlIgnore()]
public string Habilitado { get; set; }
[XmlAttribute()]
public string Tipo { get; set; }
[XmlAttribute()]
public int IdGrupo { get; set; }
}
I think you want:
var maquinasNoEncontradas = gruposCompletos
.SelectMany(g => g.Servidores)
.Select(x => x.Nombre)
.Concat(maquinasSeleccionadas)
.Where(x => !ContieneServidor(datosGruposServidores, x))
.ToList();
And then:
if (maquinasNoEncontradas.Count > 0)
{
// This assumes .NET 4; it's *slightly* more awkward in .NET 3.5, but
// still simpler than doing it by hand.
string text = string.Join(", ", maquinasNoEncontradas);
System.Diagnostics.Trace.WriteLine("Máquinas no encontradas: " + text);
throw new InvalidOperationException("Máquinas no encontradas: " + text);
}
You could potentially build the comma-separated version and then test whether that's an empty string... but I'm not sure I would, to be honest.
string.Join(", ", gruposCompletos
.SelectMany(x => x.Servidores)
.Select(x => x.Nombre)
.Concat(maquinasSeleccionadas)
.Where(x => !ContieneServidor(datosGruposServidores, x))
.ToArray());

Resources