Exemple #1
0
        public HttpResponseMessage ChangePondFeedStatus([FromBody] PondDTO uDto)
        {
            string key;
            var    ur                 = new AppUserRepository();
            var    companyId          = 0;
            var    UserId             = ur.ValidateUser(uDto.Key, out key, ref companyId);
            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Admin"))
            {
                var Pond   = new Pond();
                var errors = ValidateDtoData(uDto, Pond);
                if (errors.Any())
                {
                    return(ProcessValidationErrors(Request, errors, key));
                }
                var NEPondId = 0;
                if (int.TryParse(uDto.PondId, out NEPondId))
                {
                    //  editing existing Pond record
                    return(ChangePondFeedStatus(Request, uDto, NEPondId, key, companyId, UserId));
                }
                //  no idea what this is
                var msg = "invalid data structure submitted";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, msg));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Exemple #2
0
        private void lbl_start_Click(object sender, EventArgs e)
        {
            ReservoirCreator classCreator = type ? new Water.LakeCreator(): (ReservoirCreator)(new Water.PondCreator());
            var obj = classCreator.reservoir();

            if (obj.GetType().ToString() == "Water.Lake")
            {
                Lake lake = new Lake();
                lake.Name        = txt_name.Text;
                lake.Square      = int.Parse(txt_sq.Text);
                lake.Number      = int.Parse(txt_river.Text);
                lake.WeightWater = int.Parse(txt_weight.Text);
                lake.MaxDepth    = int.Parse(txt_.Text);
                reservoirList.Add(lake);
            }

            else if (obj.GetType().ToString() == "Water.Pond")
            {
                Pond lake = new Pond();
                lake.Name        = txt_name.Text;
                lake.Square      = int.Parse(txt_sq.Text);
                lake.Number      = int.Parse(txt_river.Text);
                lake.WeightWater = int.Parse(txt_weight.Text);
                lake.MaxDepth    = int.Parse(txt_.Text);
                reservoirList.Add(lake);
            }

            lbl_see.Visible = true;
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
0
        public GameController()
        {
            InputDataHandler.initalize();

            trainer = new Trainer();
            shark   = trainer.SharkTrain();

            pond = new Pond(shark, null);
        }
Exemple #6
0
        public HttpResponseMessage O2AddOrEdit([FromBody] O2ReadingDTO uDto)
        {
            string key;
            var    ur        = new AppUserRepository();
            var    companyId = 0;
            var    UserId    = ur.ValidateUser(uDto.Key, out key, ref companyId);

            AppUserRoleRepository aur = new AppUserRoleRepository();


            if (UserId > 0 && aur.IsInRole(UserId, "Airtime"))
            {
                var thisuser    = ur.GetById(UserId);
                var pr          = new PondRepository();
                int thisfarm    = pr.GetById(int.Parse(uDto.PondId)).FarmId;
                int UsersFarmId = thisuser.UserFarms.Where(x => x.FarmId == thisfarm).SingleOrDefault().UserFarmId;
                uDto.UsersFarmId = UsersFarmId.ToString();
                string dayperiod;
                if (DateTime.Parse(uDto.ReadingDate).Hour < 12)
                {
                    dayperiod = DateTime.Parse(uDto.ReadingDate).AddDays(-1).ToShortDateString();
                }
                else
                {
                    dayperiod = DateTime.Parse(uDto.ReadingDate).ToShortDateString();
                }
                uDto.DayPeriod = dayperiod;
                var Pond   = new Pond();
                var errors = ValidateDtoData(uDto, Pond);
                if (errors.Any())
                {
                    return(ProcessValidationErrors(Request, errors, key));
                }
                var NEReadingId = 0;
                if (int.TryParse(uDto.ReadingId, out NEReadingId))
                {
                    if (NEReadingId == -1)
                    {
                        //  creating new Pond record
                        return(ProcessNewO2Record(Request, uDto, key, companyId, UserId));
                    }
                    else
                    {
                        //  editing existing Pond record
                        return(ProcessExistingO2Record(Request, uDto, NEReadingId, key, companyId, UserId));
                    }
                }
                //  no idea what this is
                var msg = "invalid data structure submitted";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, msg));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Exemple #7
0
 void addPond()
 {
     Pond pond1 = new Pond(15, 150, carObject, this);
     Pond pond2 = new Pond(-10, 230, carObject, this);
     Pond pond3 = new Pond(0, 260, carObject, this);
     Pond pond4 = new Pond(18, 370, carObject, this);
     Pond pond5 = new Pond(25, 510, carObject, this);
     Pond pond6 = new Pond(35, 580, carObject, this);
     Pond pond7 = new Pond(18, 650, carObject, this);
     Pond pond8 = new Pond(-20, 850, carObject, this);
 }
        public void TestCalculateMethod()
        {
            var pond = new Pond();

            for (int k = 0; k < _ponds.Count; k++)
            {
                var actual = pond.CalculateSize(_ponds[k]);

                CollectionAssert.AreEqual(_expectedResults[k], actual);
            }
        }
Exemple #9
0
        public double CalculateScore(IMLMethod network)
        {
            double ret = 0;

            for (int i = 0; i < 10; i++)
            {
                Pond p = new Pond((BasicNetwork)network, null);
                ret += p.tick(100);
            }
            return(ret / 10);
        }
Exemple #10
0
    protected virtual void Awake()
    {
        pond = Pond.Instance;
        vehicle = GetComponentInParent<Vehicle>();
        entity = vehicle.GetComponent<Entity>();

        if (randomWeightChangingDelay.To > 0)
        {
            randomWeightChangingCountdown = new Countdown(0);
        }
        ChooseRandomWeightFactor();
    }
Exemple #11
0
    void Awake()
    {
        pond = FindObjectOfType <Pond>();
        body = GetComponent <Rigidbody2D>();
        var audioSources = GetComponents <AudioSource>();

        audioSourceHigh   = audioSources[0];
        audioSourceMedium = audioSources[1];
        audioSourceLow    = audioSources[2];
        collider          = GetComponent <CapsuleCollider2D>();
        spriteRenderer    = GetComponent <SpriteRenderer>();
    }
    public List <Instruction> GetInstructions(CharacterSheet sheet)
    {
        List <Instruction> instructions = new List <Instruction>();

        Instruction getFish     = new Instruction();
        Pond        destination = null;

        foreach (Pond pond in sheet.baseCity.Ponds)
        {
            if (pond.workers.Contains(sheet))
            {
                destination = pond;
                break;
            }
        }

        if (destination == null)
        {
            foreach (Pond pond in sheet.baseCity.Ponds)
            {
                if (pond.CurrentPositions[Jobs.FISHERMAN] > 0)
                {
                    destination = pond;
                    pond.workers.Add(sheet);
                    pond.CurrentPositions[Jobs.FISHERMAN]--;
                    break;
                }
            }
        }

        getFish.destination = destination.gameObject.GetComponent <NavigationWaypoint>();
        getFish.building    = destination;

        getFish.gather = new ItemType[] { ItemType.FISH };
        getFish.give   = new ItemType[] { };
        getFish.recipe = MasterRecipe.Instance.Fish;
        getFish.fun1   = new instructionFunction((getFish.building).MakeRecipe);

        instructions.Add(getFish);

        Instruction storeFish = new Instruction();

        storeFish.destination = sheet.baseCity.Barns[0].gameObject.GetComponent <NavigationWaypoint>();
        storeFish.building    = sheet.baseCity.Barns[0];
        storeFish.gather      = new ItemType[] { };
        storeFish.give        = new ItemType[] { ItemType.FISH };
        storeFish.fun1        = new instructionFunction((storeFish.building).StoreItem);
        storeFish.fun2        = new instructionFunction2((getFish.building).ReleaseJob);
        instructions.Add(storeFish);

        return(instructions);
    }
Exemple #13
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));
        }
Exemple #14
0
        private async Task <Pond> CreatePondAsync()
        {
            var frogden = new Pond {
                Name = "Frogden"
            };

            // the basket that's returned is the same basket that was passed in, so if we had a reference to the original
            // basket we could continue to refer back to this - there are examples of this later
            var basket = await _pondMine.SendAsync(new PostBasket <Pond, int>(frogden)).ConfigureAwait(false);

            frogden.Id = basket.AscentPayload;

            return(frogden);
        }
Exemple #15
0
        private void Inhabit(Pond pond)
        {
            var frogam = new Frog {
                Name = "Frogam", IsMale = true, LivesInPondId = pond.Id, DateOfBirth = _day
            };
            var freve = new Frog {
                Name = "Freve", IsMale = false, LivesInPondId = pond.Id, DateOfBirth = _day
            };

            Task.WaitAll(
                _frogMine.SendAsync(new PostBasket <Frog, int>(frogam)),
                _frogMine.SendAsync(new PostBasket <Frog, int>(freve))
                );
        }
Exemple #16
0
        private void Inhabit(Pond pond)
        {
            var frogam = new Frog {
                Name = "Frogam", IsMale = true, LivesInPondId = pond.Id, DateOfBirth = _day
            };
            var freve = new Frog {
                Name = "Freve", IsMale = false, LivesInPondId = pond.Id, DateOfBirth = _day
            };

            var postFrogamTask = _client.PostAsJsonAsync("frogs", frogam)
                                 .ContinueWith(t => EnsureSuccess(t.Result), TaskContinuationOptions.OnlyOnRanToCompletion);

            var postFreveTask = _client.PostAsJsonAsync("frogs", freve)
                                .ContinueWith(t => EnsureSuccess(t.Result), TaskContinuationOptions.OnlyOnRanToCompletion);

            Task.WaitAll(postFrogamTask, postFreveTask);
        }
Exemple #17
0
        public void MakeAllDucksSwim()
        {
            var pond = new Pond();

            pond.AddDuck(new Duck());
            pond.AddDuck(new Duck());
            pond.AddDuck(new Duck());
            pond.AddDuck(new Duck());
            pond.AddDuck(new MechanicalDuck());
            pond.AddDuck(new MechanicalDuck());
            pond.AddDuck(new MechanicalDuck());
            pond.AddDuck(new MechanicalDuck());

            pond.MakeAllDucksSwim();

            List<IDuck> swimmingDucks = pond.Ducks.Where(x => x.IsSwimming).ToList();
        }
Exemple #18
0
    public override void Enter(object extraData = null)
    {
        base.Enter(extraData);

        // extraData에는 연못(buildingBase가 들어있을 것이다)
        targetPond = extraData as Pond;
        if (targetPond == null)
        {
            Debug.LogError("Fishing은 Enter로 낚시할 연못의 buildingBase를 전달 해야한다.");
            return;
        }

        currentState = "goToPond"; // pond로 걸어가자.
        owner.Move(targetPond.transform.position);

        isWorkOver = false;
    }
Exemple #19
0
        static void Main(string[] args)
        {
            var pond = new Pond();

            pond.AddDuck(new Duck());
            pond.AddDuck(new Duck());
            pond.AddDuck(new Duck());
            pond.AddDuck(new Duck());
            pond.AddDuck(new MechanicalDuck());
            pond.AddDuck(new MechanicalDuck());
            pond.AddDuck(new MechanicalDuck());
            pond.AddDuck(new MechanicalDuck());

            pond.MakeAllDucksSwim();

            List <IDuck> swimmingDucks = pond.Ducks.Where(x => x.IsSwimming).ToList();
        }
Exemple #20
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));
        }
Exemple #21
0
        private async Task <Pond> CreatePondAsync()
        {
            var frogden = new Pond {
                Name = "Frogden"
            };

            using (var response = await _client.PostAsJsonAsync("ponds", frogden))
            {
                EnsureSuccess(response);
                frogden.Id = await response.Content.ReadAsAsync <int>();

                if (frogden.Id <= 0)
                {
                    throw new InvalidOperationException("Did not receive pond Id from server");
                }
            }

            return(frogden);
        }
Exemple #22
0
        public HttpResponseMessage ProductionTotals([FromBody] ProductionTotalDTO 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 ProductionTotalRepository();
                var u  = new ProductionTotal();
                if (cqDTO.ProductionDate != null)
                {
                    cqDTO.Start_ProductionDate = DateTime.Parse(cqDTO.ProductionDate).ToString();
                    cqDTO.End_ProductionDate   = DateTime.Parse(cqDTO.ProductionDate).AddDays(1).ToString();
                }
                else
                {
                    int sm = int.Parse(cqDTO.StartDateMonth);
                    if (sm == 1)
                    {
                        cqDTO.Start_ProductionDate = DateTime.Parse("12/23/" + (int.Parse(cqDTO.StartDateYear) - 1).ToString()).ToString();
                        cqDTO.End_ProductionDate   = DateTime.Parse("2/14/" + cqDTO.StartDateYear).ToString();
                    }
                    else if (sm == 12)
                    {
                        cqDTO.Start_ProductionDate = DateTime.Parse("11/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_ProductionDate   = DateTime.Parse("1/14/" + (int.Parse(cqDTO.StartDateYear) + 1).ToString()).ToString();
                    }
                    else
                    {
                        cqDTO.Start_ProductionDate = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) - 1).ToString() + "/23/" + cqDTO.StartDateYear).ToString();
                        cqDTO.End_ProductionDate   = DateTime.Parse((int.Parse(cqDTO.StartDateMonth) + 1).ToString() + "/14/" + cqDTO.StartDateYear).ToString();
                    }

                    cqDTO.StartDateMonth = null;
                    cqDTO.StartDateYear  = null;
                }
                SGApp.DTOs.GenericDTO dto = new GenericDTO();
                dto.StartDate = DateTime.Parse(cqDTO.Start_ProductionDate);
                dto.EndDate   = DateTime.Parse(cqDTO.End_ProductionDate);
                List <DTOs.Sampling> samplingResults = new List <DTOs.Sampling>();
                PondRepository       pr = new PondRepository();
                var client = new HttpClient
                {
                    //BaseAddress = new Uri("http://323-booth-svr2:3030/")
                    BaseAddress = new Uri("http://64.139.95.243:7846/")
                                  //BaseAddress = new Uri(baseAddress)
                };
                try
                {
                    var response = client.PostAsJsonAsync("api/Remote/GetKeithsData", dto).Result;
                    response.EnsureSuccessStatusCode();
                    JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                    //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(response.Content.ReadAsStringAsync().Result); // new List<Sampling>();
                    //Sampling[] samplingResultsArray = response.Content.ReadAsAsync<Sampling[]>().Result;
                    //samplingResults = samplingResultsArray.ToList();
                    //JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                    //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(Constants.testdata);
                    DTOs.Sampling[] samplingResultsArray = json_serializer.Deserialize <DTOs.Sampling[]>(response.Content.ReadAsStringAsync().Result);
                    samplingResults = samplingResultsArray.ToList();
                    samplingResults = samplingResults.GroupBy(x => x.farmPond).Select(group => group.First()).ToList();
                    //var result = response.Content.ReadAsStringAsync().Result;

                    //return Request.CreateResponse(HttpStatusCode.OK, result);
                }
                catch (Exception e)
                {
                    throw new HttpException("Error occurred: " + e.Message);
                }
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                data = data.OrderBy(x => x.ProductionDate).ToList();

                foreach (DTOs.Sampling sam in samplingResults)
                {
                    ProductionTotal fy  = data.Where(x => x.Pond.InnovaName == sam.farmPond).FirstOrDefault();
                    Pond            pd  = pr.GetPondFromInnovaName(sam.farmPond);
                    var             dic = new Dictionary <string, string>();
                    if (fy != null)
                    {
                        var wb = fy.WeighBacks != null ? fy.WeighBacks : 0;
                        dic.Add("ProductionTotalId", fy.ProductionTotalID.ToString());
                        dic.Add("PondID", fy.PondId.ToString());
                        dic.Add("PondName", sam.farmPond);
                        dic.Add("FarmID", fy.Pond.FarmId.ToString());
                        dic.Add("ProductionDate", fy.ProductionDate.ToShortDateString());
                        dic.Add("PlantWeight", fy.PlantWeight != null ? fy.PlantWeight.ToString() : "---");
                        dic.Add("PondWeight", fy.PondWeight != null ? fy.PondWeight.ToString() : "---");
                        dic.Add("WeighBacks", fy.WeighBacks != null ? fy.WeighBacks.ToString() : "---");
                        dic.Add("AverageYield", fy.AverageYield != null ? fy.AverageYield.ToString() : "---");
                        dic.Add("HeadedWeight", fy.AverageYield != null && fy.PlantWeight != null ? String.Format("{0:0.00}", ((fy.AverageYield / 100) * (fy.PlantWeight - wb))) : "---");
                    }
                    else
                    {
                        dic.Add("ProductionTotalId", "-1");
                        dic.Add("PondID", pd.PondId.ToString() != null ? pd.PondId.ToString() : "");
                        dic.Add("PondName", sam.farmPond != null ? sam.farmPond : "");
                        dic.Add("FarmID", pd.FarmId.ToString() != null ? pd.FarmId.ToString() : "");
                        dic.Add("ProductionDate", cqDTO.ProductionDate);
                        dic.Add("PlantWeight", "---");
                        dic.Add("PondWeight", "---");
                        dic.Add("WeighBacks", "---");
                        dic.Add("AverageYield", "---");
                        dic.Add("HeadedWeight", "---");
                    }

                    col.Add(dic);
                }
                //foreach (FarmYield fy in data)
                //{

                //    Sampling samp = samplingResults.Where(x => x.farmPond == fy.Pond.InnovaName).FirstOrDefault();
                //    var dic = new Dictionary<string, string>();
                //    if (samp == null)
                //    {
                //        dic.Add("YieldId", fy.YieldID.ToString());
                //        dic.Add("PondID", fy.PondID.ToString());
                //        dic.Add("PondName", fy.Pond.InnovaName != null ? fy.Pond.InnovaName : fy.Pond.PondName);
                //        dic.Add("FarmID", fy.Pond.FarmId.ToString());
                //        dic.Add("YieldDate", fy.YieldDate.ToShortDateString());
                //        dic.Add("PoundsYielded", fy.PoundsYielded.ToString());
                //        dic.Add("PoundsPlant", fy.PoundsPlant.ToString());
                //        dic.Add("PoundsHeaded", fy.PoundsHeaded.ToString());
                //        dic.Add("PercentYield", fy.PercentYield.ToString());
                //        dic.Add("PercentYield2", fy.PercentYield2.ToString());
                //        col.Add(dic);
                //    }


                //}

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(Request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Exemple #23
0
        private List <DbValidationError> GetValidationErrors(PondRepository pr, Pond contact, PondDTO cqDto, int companyId, int PondId)
        {
            contact.ProcessRecord(cqDto);

            return(pr.Validate(contact));
        }
Exemple #24
0
        internal HttpResponseMessage Ponds(HttpRequestMessage request, PondDTO cqDTO)
        {
            string key;
            var    aur                 = new AppUserRepository();
            var    companyId           = 0;
            var    UserId              = aur.ValidateUser(cqDTO.Key, out key, ref companyId);
            AppUserRoleRepository aur1 = new AppUserRoleRepository();


            if (UserId > 0 && aur1.IsInRole(UserId, "User"))
            {
                var ur        = new PondRepository();
                var u         = new Pond();
                var predicate = ur.GetPredicate(cqDTO, u, companyId);
                var data      = ur.GetByPredicate(predicate);
                var col       = new Collection <Dictionary <string, string> >();
                var bins      = new Collection <Dictionary <string, string> >();
                if (cqDTO.FarmId != null)
                {
                    var br      = new BinRepository();
                    var binList = br.GetFarmBinList(int.Parse(cqDTO.FarmId));
                    foreach (var bin in binList)
                    {
                        bins.Add(
                            new Dictionary <string, string>()
                        {
                            { "BinID", bin.BinID.ToString() },
                            { "BinName", bin.BinName },
                            { "FarmID", bin.FarmID.HasValue ? bin.FarmID.Value.ToString() : "" },
                            { "CurrentTicket", bin.CurrentTicket.HasValue ? bin.CurrentTicket.Value.ToString() : "" },
                            { "CurrentPounds", bin.CurrentPounds.HasValue ? bin.CurrentPounds.Value.ToString() : "" },
                            { "LastDispersement", bin.LastDisbursement.HasValue ? bin.LastDisbursement.Value.ToShortDateString() : "" },
                            { "LastLoaded", bin.LastLoaded.HasValue ? bin.LastLoaded.Value.ToShortDateString() : "" }
                        }
                            );
                    }
                }
                var farmCol = new Collection <Tuple <int, int> >();
                foreach (var item in data)
                {
                    var dic = new Dictionary <string, string>();
                    dic.Add("PondId", item.PondId.ToString());
                    dic.Add("PondName", item.PondName);
                    dic.Add("StatusId", item.StatusId.ToString());
                    dic.Add("InnovaName", item.InnovaName != null ? item.InnovaName : "");
                    dic.Add("InnovaCode", item.InnovaCode != null ? item.InnovaCode : "");
                    dic.Add("Size", item.Size.ToString());
                    dic.Add("NoFeed", item.NoFeed.ToString());
                    int poundsfedsinceharvest = 0;
                    if (item.Harvests.OrderByDescending(x => x.HarvestDate).FirstOrDefault() != null)
                    {
                        dic.Add("LastHarvest", item.Harvests.OrderByDescending(x => x.HarvestDate).FirstOrDefault().HarvestDate.ToString());
                        poundsfedsinceharvest = item.Feedings.Where(x => x.FeedDate > item.Harvests.OrderByDescending(y => y.HarvestDate).FirstOrDefault().HarvestDate).Sum(x => x.PoundsFed);
                    }
                    else
                    {
                        dic.Add("LastHarvest", "");
                        poundsfedsinceharvest = item.Feedings.Sum(x => x.PoundsFed);
                    }
                    int salepounds = poundsfedsinceharvest / 2;
                    dic.Add("PoundsFedSinceHarvest", poundsfedsinceharvest.ToString());
                    dic.Add("SalesPoundsSinceHarvest", salepounds.ToString());
                    dic.Add("HealthStatus", item.HealthStatus.ToString());
                    col.Add(dic);
                }

                var retVal = new GenericDTO
                {
                    Key        = key,
                    ReturnData = col,
                    Bins       = bins
                };
                return(Request.CreateResponse(HttpStatusCode.OK, retVal));
            }
            var message = "validation failed";

            return(request.CreateResponse(HttpStatusCode.NotFound, message));
        }
Exemple #25
0
 protected virtual void Awake()
 {
     pond = Pond.Instance;
 }
Exemple #26
0
 void Awake()
 {
     pond        = FindObjectOfType <Pond>();
     body        = GetComponent <Rigidbody2D>();
     audioSource = GetComponent <AudioSource>();
 }