private HttpResponseMessage AddListEmail(HttpRequestMessage request, ListEmailDTO cqDto, int contactId, string key, int companyId, int userId)
        {
            var aur = new ListEmailRepository();
            var ur  = new ListEmail();

            if (cqDto.ListId != "0" && cqDto.EmailId != "0")
            {
                ur.EmailId = int.Parse(cqDto.EmailId);
                ur.ListId  = int.Parse(cqDto.ListId);
            }
            aur.Save(ur);

            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
        private HttpResponseMessage ProcessExistingListEmailRecord(HttpRequestMessage request, ListEmailDTO cqDto, int contactId, string key, int ListEmailId, int userId)
        {
            var ur   = new ListEmailRepository();
            var user = new ListEmail();

            user = ur.GetById(contactId);


            var validationErrors = GetListEmailValidationErrors(ur, user, cqDto, ListEmailId, userId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }

            ur.Save(user);


            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
        private HttpResponseMessage ProcessNewListEmailRecord(HttpRequestMessage request, ListEmailDTO uDto, string key, int ListEmailId, int userId)
        {
            var ur   = new ListEmailRepository();
            var user = new ListEmail();


            var validationErrors = GetListEmailValidationErrors(ur, user, uDto, ListEmailId, userId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }

            user             = ur.Save(user);
            uDto.Key         = key;
            uDto.ListEmailId = user.ListEmailId.ToString();
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);

            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = user.ListEmailId
            }));
            return(response);
        }