コード例 #1
0
        private HttpResponseMessage RemoveUserFarm(HttpRequestMessage request, UserFarmDTO cqDto, int contactId, string key, int companyId, int userId)
        {
            var aur = new UserFarmRepository();
            var ur = new UserFarm();
            if (cqDto.FarmID == "0")
            {
                foreach (UserFarm uf in aur.GetByUserId(int.Parse(cqDto.UserID)))
                {
                    aur.Delete(uf);
                }
            }
            else
            {
                ur = aur.GetByUserFarmIds(contactId, int.Parse(cqDto.FarmID));
                aur.Delete(ur);
            }

            cqDto.Key = key;
            return request.CreateResponse(HttpStatusCode.Accepted, cqDto);
        }
コード例 #2
0
        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);
        }