public string AddRecyclingCenter(XElement input)
{
try
{
RecycleCenter center = new RecycleCenter()
{
Location = input.Element("Location").Value,
Comments = input.Element("Comments").Value,
Automotive = bool.Parse(input.Element("Automotive").Value),
Electronics = bool.Parse(input.Element("Electronics").Value),
Construction = bool.Parse(input.Element("Construction").Value),
Batteries = bool.Parse(input.Element("Batteries").Value),
Garden = bool.Parse(input.Element("Garden").Value),
Glass = bool.Parse(input.Element("Glass").Value),
Hazardous = bool.Parse(input.Element("Hazardous").Value),
Household = bool.Parse(input.Element("Household").Value),
Metal = bool.Parse(input.Element("Metal").Value),
Paint = bool.Parse(input.Element("Paint").Value),
Paper = bool.Parse(input.Element("Paper").Value),
Plastic = bool.Parse(input.Element("Plastic").Value),
UserId = int.Parse(input.Element("UserId").Value)
};
string errorMessage;
int recycleId = RecyclingDAO.AddRecycleCenter(center, out errorMessage);
return "Recycling Center addition was " + (recycleId > 0 ? "successful." : ("unsuccessful. Reason: " + errorMessage));
}
catch (Exception e)
{
return String.Format("Recycling Center addition was unsuccessful. Reason: {0}", e.Message);
}
}