public HttpResponseMessage FarmsDDLByUserId([FromBody] UtilityDTO utilityDto) { string key; var ur = new AppUserRepository(); var companyId = 0; var userId = ur.ValidateUser(utilityDto.Key, out key, ref companyId); if (userId > 0) { var sr = new FarmRepository(); var data = sr.GetUserFarms(userId); var retVal = new GenericDTO(); retVal.Key = key; var col = new Collection<Dictionary<string, string>>(); foreach (var d in data.Select(farm => new Dictionary<string, string> { {"FarmId", farm.FarmId.ToString()}, {"FarmName", farm.FarmName.ToString() } } ) ) { col.Add(d); } retVal.ReturnData = col; return Request.CreateResponse(HttpStatusCode.OK, retVal); } var message = "validation failed"; return Request.CreateResponse(HttpStatusCode.NotFound, message); }