private HttpResponseMessage RemoveListEmail(HttpRequestMessage request, ListEmailDTO cqDto, int contactId, string key, int companyId, int userId) { var aur = new ListEmailRepository(); if (cqDto.ListId != "0" && cqDto.EmailId != "0") { var data = aur.GetByListAndEmail(int.Parse(cqDto.EmailId), int.Parse(cqDto.ListId)); aur.Delete(data); } cqDto.Key = key; return(request.CreateResponse(HttpStatusCode.Accepted, cqDto)); }
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)); }
internal HttpResponseMessage ListEmails(HttpRequestMessage request, ListEmailDTO cqDTO) { string key; var aur = new AppUserRepository(); var companyId = 0; var userId = aur.ValidateUser(cqDTO.Key, out key, ref companyId); if (userId > 0) { var ur = new ListEmailRepository(); var u = new ListEmail(); var predicate = ur.GetPredicate(cqDTO, u, companyId); var data = ur.GetByPredicate(predicate); var col = new Collection <Dictionary <string, string> >(); var dataArray = data.Select(x => x.EmailId).ToArray(); return(Request.CreateResponse(HttpStatusCode.OK, dataArray)); } var message = "validation failed"; return(request.CreateResponse(HttpStatusCode.NotFound, message)); }
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); }
private List <DbValidationError> GetListEmailValidationErrors(ListEmailRepository pr, ListEmail contact, ListEmailDTO cqDto, int YieldID, int userId) { contact.ProcessRecord(cqDto); return(pr.Validate(contact)); }