コード例 #1
0
        private HttpResponseMessage ProcessNewHarvestRecord(HttpRequestMessage request, HarvestDTO uDto, string key, int companyId, int UserId)
        {
            var hr = new HarvestRepository();
            var harv = new Harvest();

            var validationErrors = GetHarvestValidationErrors(hr, harv, uDto, companyId, UserId);

            if (validationErrors.Any())
            {
                return ProcessValidationErrors(request, validationErrors, key);
            }
            //  no validation errors...
            //Pond.CompanyId = companyId;

            harv = hr.Save(harv);
            uDto.Key = key;
            uDto.HarvestId = harv.HarvestId.ToString();
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);
            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = harv.HarvestId
            }));
            return response;
        }
コード例 #2
0
        private List<DbValidationError> GetHarvestValidationErrors(HarvestRepository pr, Harvest contact, HarvestDTO cqDto, int companyId, int PondId)
        {
            contact.ProcessRecord(cqDto);

            return pr.Validate(contact);
        }