public AddEditFlowerPlotViewModel(FlowerPlotIteration flowerPlot, Window addEditFlowerPlotWindow, bool add, BindingList <FlowerPlotIteration> myFlowerPlots, Visibility addnextstage)
        {
            this.myFlowerPlots           = myFlowerPlots;
            MyFlowerPlot                 = flowerPlot;
            this.addEditFlowerPlotWindow = addEditFlowerPlotWindow;
            Add          = add;
            SoilName     = MyFlowerPlot.SoilName;
            FlowerName   = MyFlowerPlot.FlowerName;
            AddNextStage = addnextstage;

            ExitCommand      = new MyICommand(Exit);
            NextStageCommand = new MyICommand(NextStage);

            mySoiltype = new List <SoilType>(SoilProxy.Instance.Proxy.GetAllSoilsType());
            MySoiltype = (from o in mySoiltype
                          select o.ToString()).ToList();

            myFlowerType = new List <Flower>(FlowerProxy.Instance.Proxy.GetAllFlowersType());
            MyFlowertype = (from o in myFlowerType
                            select o.ToString()).ToList();

            SaveFlowerPlotCommand = new MyICommand(SaveUserFlowerPlot, CanSaveFlowerPlot);

            NewFlowerPlot    = MyFlowerPlot.Clone();
            NextStageChanged = true;
        }
Example #2
0
        public bool EditFlowerPlot(FlowerPlotIteration flower, out long time)
        {
            using (IUnitOfWork unit = new UnitOfWork(new Context()))
            {
                FlowerPlotIteration f = unit.Flowers.Get(flower.Id);
                if (f != null)
                {
                    if (flower.LastChange != f.LastChange)
                    {
                        time = 0;
                        return(false);
                    }

                    flower.LastChange = DateTime.Now.Ticks;

                    unit.Flowers.Remove(f);
                    unit.Flowers.Add(flower);

                    unit.Complete();
                    time = flower.LastChange;
                    return(true);
                }

                time = 0;
                return(false);
            }
        }
Example #3
0
 public void DeleteFlowerPlotOverride(FlowerPlotIteration flowerPlot)
 {
     lock (lockObject)
     {
         using (IUnitOfWork unit = new UnitOfWork(new Context()))
         {
             FlowerPlotIteration flower = unit.Flowers.Get(flowerPlot.Id);
             if (flower != null) //postoji obrisi
             {
                 unit.Flowers.Remove(flower);
                 unit.Complete();
             }
         }
     }
 }
Example #4
0
 public bool AddFlowerPlot(FlowerPlotIteration flower)
 {
     using (IUnitOfWork unit = new UnitOfWork(new Context()))
     {
         FlowerPlotIteration f = unit.Flowers.Get(flower.Id);
         if (f == null) //ako takvav user ne postoji,dodaj
         {
             unit.Flowers.Add(flower);
             unit.Complete();
             FlowerPlotIteration f1 = unit.Flowers.Get(flower.Id);
             return(true);
         }
         return(false);
     }
 }
Example #5
0
        public void EditFlowerPlotOverride(FlowerPlotIteration flower, out long time)
        {
            lock (lockObject)
            {
                using (IUnitOfWork unit = new UnitOfWork(new Context()))
                {
                    FlowerPlotIteration f = unit.Flowers.Get(flower.Id);
                    if (f != null)
                    {
                        unit.Flowers.Remove(f);
                    }

                    flower.LastChange = DateTime.Now.Ticks;
                    time = flower.LastChange;
                    unit.Flowers.Add(flower);

                    unit.Complete();
                }
            }
        }
Example #6
0
        public bool DeleteFlowerPlot(FlowerPlotIteration flowerPlot)
        {
            using (IUnitOfWork unit = new UnitOfWork(new Context()))
            {
                FlowerPlotIteration flower = unit.Flowers.Get(flowerPlot.Id);
                if (flower != null) //postoji obrisi
                {
                    if (flowerPlot.LastChange != flower.LastChange)
                    {
                        return(false);
                    }

                    unit.Flowers.Remove(flower);
                    unit.Complete();
                    return(true);
                }

                return(true);
            }
        }
Example #7
0
        private static void AddToBase()
        {
            using (IUnitOfWork context = new UnitOfWork(new Context()))
            {
                context.DeleteDatabase();
                User adminUser = new User()
                {
                    Username = "******",
                    Password = "******",
                    Name     = "Biljana",
                    Lastname = "Vukelic",
                    TypeUser = UserTypes.ADMIN
                };

                User regularUser = new User()
                {
                    Username = "******",
                    Password = "******",
                    Name     = "obican",
                    Lastname = "obican",
                    TypeUser = UserTypes.REGULAR
                };


                SoilType soil1 = new SoilType()
                {
                    SoilName    = "Smonica",
                    ClayPercent = 20,
                    SandPercent = 20,
                    SiltPercent = 60
                };
                SoilType soil2 = new SoilType()
                {
                    SoilName    = "Crnica",
                    ClayPercent = 80,
                    SandPercent = 10,
                    SiltPercent = 10
                };
                SoilType soil3 = new SoilType()
                {
                    SoilName    = "Gajnjaca",
                    ClayPercent = 70,
                    SandPercent = 20,
                    SiltPercent = 10
                };

                Flower flower1 = new Flower()
                {
                    FlowerName = "Ruza"
                };

                Flower flower2 = new Flower()
                {
                    FlowerName = "Gerber"
                };

                Flower flower3 = new Flower()
                {
                    FlowerName = "Bozur"
                };

                FlowerPlotIteration flowerPlot1 = new FlowerPlotIteration()
                {
                    Area         = 5,
                    Id           = 501,
                    Stage        = StageTypes.Idle,
                    HarvestDate  = DateTime.Now,
                    MoisturePerc = 10,
                    PlantingDate = DateTime.Now,
                    FlowerName   = "Ruza",
                    SoilName     = "Crnica[Clay:80% Sand:10% Slit:10%]",
                    LastChange   = DateTime.Now.Ticks
                };

                FlowerPlotIteration flowerPlot2 = new FlowerPlotIteration()
                {
                    Area         = 6,
                    Id           = 502,
                    Stage        = StageTypes.Planted,
                    HarvestDate  = DateTime.Now,
                    MoisturePerc = 20,
                    PlantingDate = DateTime.Now,
                    FlowerName   = "Gerber",
                    SoilName     = "Smonica[Clay:20% Sand:20% Slit:60%]",
                    LastChange   = DateTime.Now.Ticks
                };

                FlowerPlotIteration flowerPlot3 = new FlowerPlotIteration()
                {
                    Area         = 7,
                    Id           = 503,
                    Stage        = StageTypes.Bloomed,
                    HarvestDate  = DateTime.Now,
                    MoisturePerc = 30,
                    PlantingDate = DateTime.Now,
                    FlowerName   = "Bozur",
                    SoilName     = "Gajnjaca[Clay:70% Sand:20% Slit:10%]",
                    LastChange   = DateTime.Now.Ticks
                };

                try
                {
                    context.Users.Add(adminUser);
                    context.Users.Add(regularUser);
                    context.Soils.Add(soil1);
                    context.Soils.Add(soil2);
                    context.Soils.Add(soil3);
                    context.FlowersType.Add(flower1);
                    context.FlowersType.Add(flower2);
                    context.FlowersType.Add(flower3);
                    context.Flowers.Add(flowerPlot1);
                    context.Flowers.Add(flowerPlot2);
                    context.Flowers.Add(flowerPlot3);

                    context.Complete();
                }
                catch (Exception)
                {
                    LogManager.GetLogger("Server").Debug("Error with adding to base.");
                }
            }
        }