コード例 #1
0
        private HttpResponseMessage ProcessNewFarmYieldRecord(HttpRequestMessage request, FarmYieldDTO uDto, string key, int FarmYieldId, int userId)
        {
            var ur   = new FarmYieldRepository();
            var user = new FarmYield();


            var validationErrors = GetValidationErrors(ur, user, uDto, FarmYieldId, userId);

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

            user         = ur.Save(user);
            uDto.Key     = key;
            uDto.YieldID = user.YieldID.ToString();


            UpdateProductionTotalYield(uDto);
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);

            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = user.YieldID
            }));
            return(response);
        }
コード例 #2
0
        private HttpResponseMessage ProcessExistingFarmYieldRecord(HttpRequestMessage request, FarmYieldDTO cqDto, int contactId, string key, int FarmYieldId, int userId)
        {
            var ur   = new FarmYieldRepository();
            var user = new FarmYield();

            user = ur.GetById(contactId);


            var validationErrors = GetValidationErrors(ur, user, cqDto, FarmYieldId, userId);

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

            if (cqDto.Remove != null && int.Parse(cqDto.Remove) == 1)
            {
                ur.Delete(user);
            }
            else
            {
                ur.Save(user);
            }
            UpdateProductionTotalYield(cqDto);
            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
コード例 #3
0
        private HttpResponseMessage ProcessNewFarmYieldRecord(HttpRequestMessage request, FarmYieldDTO uDto, string key, int FarmYieldId, int userId)
        {
            var ur = new FarmYieldRepository();
            var user = new FarmYield();

            var validationErrors = GetValidationErrors(ur, user, uDto, FarmYieldId, userId);

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

            user = ur.Save(user);
            uDto.Key = key;
            uDto.YieldID = user.YieldID.ToString();

            UpdateProductionTotalYield(uDto);
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);
            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = user.YieldID
            }));
            return response;
        }
コード例 #4
0
        private HttpResponseMessage ProcessExistingFarmYieldRecord(HttpRequestMessage request, FarmYieldDTO cqDto, int contactId, string key, int FarmYieldId, int userId)
        {
            var ur = new FarmYieldRepository();
            var user = new FarmYield();
            user = ur.GetById(contactId);

            var validationErrors = GetValidationErrors(ur, user, cqDto, FarmYieldId, userId);
            if (validationErrors.Any())
            {
                return ProcessValidationErrors(request, validationErrors, key);
            }

            if (cqDto.Remove != null && int.Parse(cqDto.Remove) == 1)
            {
                ur.Delete(user);
            }
            else
            {
                ur.Save(user);
            }
            UpdateProductionTotalYield(cqDto);
            cqDto.Key = key;
            return request.CreateResponse(HttpStatusCode.Accepted, cqDto);
        }