I have repository class which contains a list with people who filled in a form on my website if they will attend on my party or not. I read values with the GetAllRespones and I add values to the list with AddResponse (via an interface)
Now I want to check if someone already filled in my form and if so I want to check if the value of WillAttend is changed and update it.
I can see what I did below here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PartyInvites.Abstract;
namespace PartyInvites.Models
{
public class GuestResponseRepository : IRepository
{
private static List<GuestResponse> responses = new List<GuestResponse>();
IEnumerable<GuestResponse> IRepository.GetAllResponses()
{
return responses;
}
bool IRepository.AddResponse(GuestResponse response)
{
bool exists = responses.Any(x => x.Email == response.Email);
bool existsWillAttend = responses.Any(x => x.WillAttend == response.WillAttend);
if (exists == true)
{
if (existsWillAttend == true)
{
return false;
}
var attend = responses.Any(x => x.Email == response.Email && x.WillAttend == response.WillAttend);
attend.WillAttend = response.WillAttend;
return true;
}
responses.Add(response);
return true;
}
}
}
the problem is, i get a error message at "attend.WillAttend"
the error is: bool does not contain definition for WillAttend and has no extension method 'WillAttend' accepting a first argument of type bool could be found
Could anyone help me out fix my code? :)