private HttpResponseMessage ProcessExistingFeedRecord(HttpRequestMessage request, FeedingDTO cqDto, int contactId, string key, int companyId, int UserId) { var o2r = new FeedingRepository(); var o2 = new Feeding(); o2 = o2r.GetById(contactId); // is the Pond eligible to update the prospect? var validationErrors = GetFeedValidationErrors(o2r, o2, cqDto, companyId, UserId); if (validationErrors.Any()) { return ProcessValidationErrors(request, validationErrors, key); } // no validation errors... o2r.Save(o2); cqDto.Key = key; return request.CreateResponse(HttpStatusCode.Accepted, cqDto); }
private HttpResponseMessage ProcessNewFeedRecord(HttpRequestMessage request, FeedingDTO uDto, string key, int companyId, int UserId) { var ur = new FeedingRepository(); var o2 = new Feeding(); var validationErrors = GetFeedValidationErrors(ur, o2, uDto, companyId, UserId); if (validationErrors.Any()) { return ProcessValidationErrors(request, validationErrors, key); } // no validation errors... //Pond.CompanyId = companyId; o2 = ur.Save(o2); uDto.Key = key; var response = request.CreateResponse(HttpStatusCode.Created, uDto); response.Headers.Location = new Uri(Url.Link("Default", new { id = o2.FeedingId })); return response; }
private List<DbValidationError> GetFeedValidationErrors(FeedingRepository pr, Feeding contact, FeedingDTO cqDto, int companyId, int PondId) { contact.ProcessRecord(cqDto); return pr.Validate(contact); }