Exemplo n.º 1
0
        private HttpResponseMessage ProcessNewPondRecord(HttpRequestMessage request, PondDTO uDto, string key, int companyId, int UserId)
        {
            var ur   = new PondRepository();
            var Pond = new Pond();

            var validationErrors = GetValidationErrors(ur, Pond, uDto, companyId, UserId);

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

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

            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = Pond.PondId
            }));
            return(response);
        }
Exemplo n.º 2
0
        private void UpdatePondHealthStatusByLevel(int pondid, decimal o2level)
        {
            var ur   = new PondRepository();
            var Pond = new Pond();

            Pond = ur.GetById(pondid);
            var or = new O2ReadingRepository();
            List <O2Reading> last2 = or.GetLast2PondReadingsByPond(pondid);


            if (o2level < (decimal)(2.5))
            {
                Pond.HealthStatus = 3;
            }
            else if (last2.Count == 2)
            {
                decimal readingnow  = last2.OrderByDescending(x => x.ReadingId).FirstOrDefault().O2Level;
                decimal readinglast = last2.OrderBy(x => x.ReadingId).FirstOrDefault().O2Level;
                if (readingnow / readinglast <= (decimal).5)
                {
                    Pond.HealthStatus = 2;
                }
                else
                {
                    Pond.HealthStatus = 1;
                }
            }
            else
            {
                Pond.HealthStatus = 1;
            }
            //  no validation errors...
            ur.Save(Pond);
        }
Exemplo n.º 3
0
        private HttpResponseMessage ChangePondHealthStatus(HttpRequestMessage request, PondDTO cqDto, int contactId, string key, int companyId, int UserId)
        {
            var ur   = new PondRepository();
            var Pond = new Pond();

            Pond = ur.GetById(contactId);

            //  no validation errors...
            Pond.HealthStatus = int.Parse(cqDto.HealthStatus);
            ur.Save(Pond);
            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
Exemplo n.º 4
0
        private HttpResponseMessage ProcessExistingPondRecord(HttpRequestMessage request, PondDTO cqDto, int contactId, string key, int companyId, int UserId)
        {
            var ur   = new PondRepository();
            var Pond = new Pond();

            Pond = ur.GetById(contactId);
            //  is the Pond eligible to update the prospect?

            var validationErrors = GetValidationErrors(ur, Pond, cqDto, companyId, UserId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }
            //  no validation errors...
            ur.Save(Pond);
            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
        private void UpdatePondHealthStatusByLevel(int pondid, decimal o2level)
        {
            var ur = new PondRepository();
            var Pond = new Pond();
            Pond = ur.GetById(pondid);
            var or = new O2ReadingRepository();
            List<O2Reading> last2 = or.GetLast2PondReadingsByPond(pondid);

            if (o2level < (decimal)(2.5))
            {
                Pond.HealthStatus = 3;
            }
            else if (last2.Count == 2)
            {

                decimal readingnow = last2.OrderByDescending(x => x.ReadingId).FirstOrDefault().O2Level;
                decimal readinglast = last2.OrderBy(x => x.ReadingId).FirstOrDefault().O2Level;
                if (readingnow / readinglast <= (decimal).5)
                {

                    Pond.HealthStatus = 2;
                }
                else
                {
                    Pond.HealthStatus = 1;

                }
            }
            else
            {
                Pond.HealthStatus = 1;
            }
            //  no validation errors...
            ur.Save(Pond);
        }
        private HttpResponseMessage ProcessNewPondRecord(HttpRequestMessage request, PondDTO uDto, string key, int companyId, int UserId)
        {
            var ur = new PondRepository();
            var Pond = new Pond();

            var validationErrors = GetValidationErrors(ur, Pond, uDto, companyId, UserId);

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

            Pond = ur.Save(Pond);
            uDto.Key = key;
            uDto.PondId = Pond.PondId.ToString();
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);
            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = Pond.PondId
            }));
            return response;
        }
        private HttpResponseMessage ProcessExistingPondRecord(HttpRequestMessage request, PondDTO cqDto, int contactId, string key, int companyId, int UserId)
        {
            var ur = new PondRepository();
            var Pond = new Pond();
            Pond = ur.GetById(contactId);
            //  is the Pond eligible to update the prospect?

            var validationErrors = GetValidationErrors(ur, Pond, cqDto, companyId, UserId);
            if (validationErrors.Any())
            {
                return ProcessValidationErrors(request, validationErrors, key);
            }
            //  no validation errors...
            ur.Save(Pond);
            cqDto.Key = key;
            return request.CreateResponse(HttpStatusCode.Accepted, cqDto);
        }
        private HttpResponseMessage ChangePondStatus(HttpRequestMessage request, PondDTO cqDto, int contactId, string key, int companyId, int UserId)
        {
            var ur = new PondRepository();
            var Pond = new Pond();
            Pond = ur.GetById(contactId);

            //  no validation errors...
            Pond.StatusId = int.Parse(cqDto.StatusId);
            ur.Save(Pond);
            cqDto.Key = key;
            return request.CreateResponse(HttpStatusCode.Accepted, cqDto);
        }