private HttpResponseMessage AddUserFarm(HttpRequestMessage request, UserFarmDTO cqDto, int contactId, string key, int companyId, int userId) { var aur = new UserFarmRepository(); var ur = new UserFarm(); //ur = aur.GetByUserFarmIds(contactId, int.Parse(cqDto.FarmID)); if (cqDto.FarmID == "0") { var fr = new FarmRepository(); foreach (Farm f in fr.GetFarms()) { ur.FarmId = f.FarmId; ur.UserId = contactId; ur.StatusId = 1; aur.Save(ur); } } else { ur.FarmId = int.Parse(cqDto.FarmID); ur.UserId = contactId; ur.StatusId = 1; aur.Save(ur); } cqDto.Key = key; return(request.CreateResponse(HttpStatusCode.Accepted, cqDto)); }
private HttpResponseMessage AddUserFarm(HttpRequestMessage request, UserFarmDTO cqDto, int contactId, string key, int companyId, int userId) { var aur = new UserFarmRepository(); var ur = new UserFarm(); //ur = aur.GetByUserFarmIds(contactId, int.Parse(cqDto.FarmID)); if (cqDto.FarmID == "0") { var fr = new FarmRepository(); foreach (Farm f in fr.GetFarms()) { ur.FarmId = f.FarmId; ur.UserId = contactId; ur.StatusId = 1; aur.Save(ur); } } else { ur.FarmId = int.Parse(cqDto.FarmID); ur.UserId = contactId; ur.StatusId = 1; aur.Save(ur); } cqDto.Key = key; return request.CreateResponse(HttpStatusCode.Accepted, cqDto); }