protected virtual void ProcessInput(string input)
        {
            string[] inputCommands = input.Split(' ');

            string action = inputCommands[0];

            switch (action)
            {
                case "create":
                    {
                        string farmId = inputCommands[1];
                        this.farm = new Farm(farmId);
                    }
                    break;
                case "add":
                    {
                        this.AddObjectToFarm(inputCommands);
                    }
                    break;
                case "status":
                    {
                        this.PrintObjectStatus(inputCommands);
                    }
                    break;
                default:
                    break;
            }    
        }
Example #2
0
        /// <summary>
        /// Creating Farm and a default plot
        /// </summary>
        /// <param name="farm">FarmInfo Model Object as a parameter</param>
        public void CreateFarmPlot(FarmInfo farm)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            if (dao.GetCountOfFarmsForFarmNameOnUser(farm.UserId, farm.FarmName) == 0)
            {
                dao.CreateFarmPlot(farm);
            }
            else
            {
                throw new Exception("Farm Name Already Exist");
            }
        }
Example #3
0
        /// <summary>
        /// Creating plot
        /// </summary>
        /// <param name="Plot">PlotInfo Model Object as a parameter</param>
        public void CreatePlot(PlotInfo plot)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            if (dao.GetCountOfPlotsForPlotNameOnFarm(plot.FarmId, plot.PlotName) == 0)
            {
                dao.CreatePlot(plot);
            }
            else
            {
                throw new Exception("Plot Name already exisist.");
            }
        }
Example #4
0
        /// <summary>
        /// Updating plot
        /// </summary>
        /// <param name="Plot">PlotInfo Model Object as a parameter</param>
        public void UpdatePlot(PlotInfo plot)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            if (dao.GetCountOfDuplicatePlotNameForEdit(plot.FarmId, plot.PlotId, plot.PlotName) == 0)
            {
                dao.UpdatePlot(plot);
            }
            else
            {
                throw new Exception("Plot Name Already Exist.");
            }
        }
        public void FindById_ReturnsFarm_ForKnownId(
            [NotNull] IFarm expected,
            [NotNull] FarmsRepository sut)
        {
            // Arrange
            sut.Save(expected);

            // Act
            IFarm actual = sut.FindById(expected.Id);

            // Assert
            Assert.AreEqual(expected,
                            actual);
        }
Example #6
0
        /// <summary>
        /// Updating Farm and a default plot
        /// </summary>
        /// <param name="farm">FarmInfo Model Object as a parameter</param>
        public void UpdateFarmPlot(FarmInfo farm)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            if (dao.GetCountOfDuplicateFarmNameForEdit(farm.UserId, farm.FarmId, farm.FarmName) == 0)
            {
                dao.UpdateFarmPlot(farm);
            }
            else
            {
                throw new Exception("Farm Name already Exist.");
            }
        }
 public LearnGardenController(IPermissionProvider permissionProvider,
                              IAdminUser adminUserRepository, IArticle articleService,
                              IFarm farmService, IFarmArea farmAreaService, IArea areaService,
                              INotification notificationService,
                              IFarmBooking farmBookService
                              )
     : base(permissionProvider, adminUserRepository)
 {
     _articleService      = articleService;
     _farmService         = farmService;
     _farmAreaService     = farmAreaService;
     _areaService         = areaService;
     _notificationService = notificationService;
     _farmBookService     = farmBookService;
 }
        public void SearchByFarmName_ReturnsMatchingFarms_ForSearchText(
            [NotNull] IFarm expected,
            [NotNull] FarmsRepository sut)
        {
            // Arrange
            expected.Name = "Name";
            sut.Save(expected);

            // Act
            IQueryable <IFarm> actual = sut.SearchByFarmName("Na");

            // Assert
            Assert.AreEqual(expected,
                            actual.First());
        }
Example #9
0
        /// <summary>
        /// To Delete a Farm
        /// </summary>
        /// <param name="farmId">Farm Id of the Farm to be deleted</param>
        /// <param name="lastModifyBy">Last Modified By User Id</param>
        public void DeleteFarm(int farmId, int lastModifyBy)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            //Check if there is a Plot/s attached to the farm.
            if (dao.GetPlotCountForFarm(farmId) == 0)
            {
                dao.DeleteFarm(farmId, lastModifyBy);
            }
            else
            {
                throw new Exception("Farm is not Empty");
            }
        }
Example #10
0
        /// <summary>
        /// To Delete a Plot
        /// </summary>
        /// <param name="plotId">Plot Id of the Plot Which is to be deleted</param>
        /// <param name="lastModifyBy">Last Modified By User Id</param>
        public void DeletePlot(int plotId, int lastModifyBy)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            //Check if any Contacts Attached to the Farm
            if (dao.GetContactCountForPlot(plotId) == 0)
            {
                dao.DeletePlot(plotId, lastModifyBy);
            }
            else
            {
                throw new Exception("Plot is not Empty");
            }
        }
Example #11
0
        protected override void RunExample(IApplicationContext ctx)
        {
            IFarm cowFarm = ctx.GetObject <IFarm>("cowFarm");
            IFarm pigFarm = ctx.GetObject <IFarm>("pigFarm");

            Console.WriteLine("\nRunning cow farm");
            cowFarm.RunFarm();

            Console.WriteLine("\nRunning pig farm");
            pigFarm.RunFarm();

            Console.WriteLine("\nRunning cow farm for second time");
            cowFarm.RunFarm();

            Console.WriteLine("\nRunning pig farm for second time");
            pigFarm.RunFarm();
        }
        private void GetAndPublishFarm(Guid farmId)
        {
            IFarm farm = m_FarmsRepository.FindById(farmId);

            if (farm == null)
            {
                return;
            }

            IMiller miller = m_MillersRepository.FindById(farm.MillerId);

            if (miller == null)
            {
                return;
            }

            PublishFarmChangedEvent(farm,
                                    miller);
        }
        private void PublishFarmChangedEvent(IFarm farm,
                                             IMiller miller)
        {
            var dto = new FarmMillerDto
            {
                FarmId     = farm.Id,
                FieldsCode = farm.FieldsCode,
                FarmName   = farm.Name,
                Harvested  = farm.Harvested,
                FarmType   = farm.FarmType,
                MillerId   = miller.Id,
                MillerName = miller.Name
            };

            var changed = new FarmChangedEvent
            {
                FarmMillerDto = dto
            };

            m_EventAggregator.PublishOnBackgroundThread(changed);
        }
Example #14
0
 public Farmer(IMommy mommy, IDaddy daddy, IFarm farm)
 {
 }
Example #15
0
 public EthGetworkClient(IFarm f, int workTimeout, int farmRecheckPeriod) : base()
 {
     _workTimeout       = workTimeout;
     _farmRecheckPeriod = farmRecheckPeriod;
 }
 public RegisterFarmResponse(IFarm farm)
 {
     Id   = farm.Id;
     Name = farm.Name;
 }
Example #17
0
 public AnimalDIContainer(IFarm animal)
 {
     _animal = animal;
 }
 public FarmStandardOutput(IFarm farm)
 {
     Farm = farm;
 }
Example #19
0
 private void BuildOutput(IFarm farm)
 {
     _outputPort.Standard(new FarmStandardOutput(
                              farm)
                          );
 }
Example #20
0
 public SimulateClient(IFarm f, int block) : base("sim")
 {
     _f     = f;
     _block = block;
 }
Example #21
0
 public Farmer(IMommy mommy, IDaddy daddy, IFarm farm)
 {
 }
Example #22
0
 public HomeController(IFarm farm)
 {
     this.farm = farm;
 }
Example #23
0
 public async Task AddAsync(IFarm farm)
 {
     _context.Farms.Add((Entities.Farm)farm);
     await Task.CompletedTask
     .ConfigureAwait(false);
 }
Example #24
0
 public static string HarvestDays(this IFarm farm)
 {
     return(farm.CanHarvest ? "<size=32><color=green>READY</color></size>" : farm.Get(Matter.Biomass).CurrentAmount > 0 ? String.Format("<size=32>{0:0.#} Days</size>", (farm.HarvestThresholdInUnits - farm.Get(Matter.Biomass).CurrentAmount) / farm.BiomassProductionPerTickInUnits / SunOrbit.GameSecondsPerGameDay) : "<size=32>NEVER</size>");
 }
Example #25
0
 public static string WaterSupplyDays(this IFarm farm)
 {
     return(farm.WaterIn == null ? "0" : String.Format("{0:#.#}", farm.WaterIn.Get(Matter.Water).CurrentAmount / farm.WaterConsumptionPerTickInUnits / SunOrbit.GameSecondsPerGameDay));
 }
Example #26
0
 public static string YieldMeals(this IFarm farm)
 {
     return(String.Format("{0:0.#}", Matter.Biomass.UnitsPerCubicMeter() * farm.Get(Matter.Biomass).CurrentAmount));
 }
Example #27
0
 public static string OxygenADayKgs(this IFarm farm)
 {
     return(String.Format("{0:0.##}", Matter.Oxygen.Kilograms() * farm.OxygenProductionPerTickInUnits * SunOrbit.GameSecondsPerGameDay));
 }