Exemplo n.º 1
0
        public Memento CreateSnapshot()
        {
            Memento result = new Memento();

            result.NodeType = "ShapeStyle";
            result["name"]  = this.Name;
            result.Add(LineStyleInfo);
            result.Add(FillStyleInfo);
            result.Add(FontStyleInfo);
            return(result);
        }
Exemplo n.º 2
0
        private void btnAddToCart_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (gvSearch.SelectedItem == null)
                {
                    return;
                }
                var      c   = gvSearch.SelectedItem as GridViewItem;
                var      cb  = cbRooms.SelectedItem as ComboBoxItem;
                var      qt  = "1";
                IMemento mem = _user.ShoppingCart.Parameters;
                if (cb != null)
                {
                    if (cb.Content != null)
                    {
                        qt = cb.Content.ToString();
                    }
                }
                foreach (var service in data.Services.Where(service => c != null && Convert.ToInt32(c.Name) == service.Id))
                {
                    var s = new Service();
                    s.Clone(service);

                    s.AddValues("initialdate", dpCheckin.Date.ToString());
                    s.AddValues("enddate", dpCheckout.Date.ToString());
                    foreach (var value in s.ServiceValues.Where(value => value.Property.Name == "quantity"))
                    {
                        value.Value = qt;
                    }
                    mem = new Memento(mem);
                    mem.Add("initialdate", dpCheckin.Date.ToString());
                    mem.Add("enddate", dpCheckout.Date.ToString());
                    mem.Add("quantity", qt);
                    mem.ServiceId = s.Id;
                    _user.ShoppingCart.AddToCart(s);
                }
                _user.ShoppingCart.Parameters = mem;
            }
            catch (Exception exc)
            {
                var m = new MessageDialog(exc.Message);
                m.ShowAsync();
            }
        }
Exemplo n.º 3
0
        private void btnAddToCart_Click(object sender, RoutedEventArgs e)
        {
            if (gvSearch.SelectedItem == null)
            {
                return;
            }
            var l   = DataHolder.GetInstance().Services;
            var c   = (GridViewItem)gvSearch.SelectedItem;
            var cb  = cbPeople.SelectedItem as ComboBoxItem;
            var qt  = "1";
            var mem = _user.ShoppingCart.Parameters;

            if (cb != null)
            {
                if (cb.Content != null)
                {
                    qt = cb.Content.ToString();
                }
            }
            foreach (var service in data.Services.Where(service => c != null && Convert.ToInt32(c.Name) == service.Id))
            {
                var s = new Service();
                s.Clone(service);

                s.AddValues("date", dpDate.Date.ToString());
                s.AddValues("initialtime", tpTime.Time.ToString());
                foreach (var value in s.ServiceValues.Where(value => value.Property.Name == "quantity"))
                {
                    value.Value = qt;
                }
                mem = new Memento(mem);
                mem.Add("date", dpDate.Date.ToString());
                mem.Add("initialtime", tpTime.Time.ToString());
                mem.Add("quantity", qt);
                mem.ServiceId = s.Id;
                _user.ShoppingCart.AddToCart(s);
            }
            _user.ShoppingCart.Parameters = mem;

            btnShoppingCart.Label = "Shopping Cart(" + _user.ShoppingCart.Num + ")";

            btnShoppingCart.Label = "Shopping Cart(" + _user.ShoppingCart.Num + ")";
        }
Exemplo n.º 4
0
        public void AddChildrenToSnapshot(Memento storage)
        {
            IEnumerable <Block> children = GetChildrenToSerialize();

            if (children != null)
            {
                foreach (Block b in children)
                {
                    storage.Add(b.CreateSnapshot());
                }
            }
        }
Exemplo n.º 5
0
        public Memento CreateSnapshot()
        {
            Memento result = new Memento();

            result.NodeType = "ShapeStyles";
            foreach (KeyValuePair <string, IShapeStyle> pair in StyleList)
            {
                Memento styleSnapshot = pair.Value.CreateSnapshot();
                styleSnapshot["name"] = pair.Key;
                result.Add(styleSnapshot);
            }
            return(result);
        }
Exemplo n.º 6
0
        public override bool CheckAvailability(IMemento aParam, IService aService)
        {
            var aux         = aParam.GetById(aService.Id);
            var initialDate = Convert.ToDateTime(aux.Get("initialdate"));
            var endDate     = Convert.ToDateTime(aux.Get("enddate"));
            var qt          = 0;
            var ans         = true;

            for (var i = 0; i < Convert.ToInt32((endDate - initialDate).Days); i++)
            {
                foreach (var serv in DataHolder.GetInstance().Reservations.Where(date => date.Id == aService.Id))
                {
                    var ini = new DateTime();
                    foreach (var start in serv.ServiceValues.Where(start => start.Property.Name == "initialdate"))
                    {
                        ini = Convert.ToDateTime(start.Value);
                    }

                    var end = new DateTime();
                    foreach (var endo in serv.ServiceValues.Where(endo => endo.Property.Name == "initialdate"))
                    {
                        end = Convert.ToDateTime(endo.Value);
                    }

                    if (ini.DayOfYear <= initialDate.DayOfYear && initialDate.DayOfYear <= end.DayOfYear)
                    {
                        foreach (var ar in serv.ServiceValues.Where(ar => ar.Property.Name == "quantity"))
                        {
                            qt += Convert.ToInt32(ar.Value);
                        }
                    }
                }
                aParam = new Memento(aParam);
                aParam.Add("qt", qt.ToString());
                ans = ans && _darthVader.CheckAvailability(aParam, aService);
                if (!ans)
                {
                    break;
                }
                initialDate.Date.AddDays(1);
            }
            return(ans);
        }
Exemplo n.º 7
0
        public override bool CheckAvailability(IMemento aParam, IService aService)
        {
            var aux         = aParam.GetById(aService.Id);
            var initialTime = aux.Get("initialtime");
            var date        = aux.Get("date");
            var iTime       = "";
            var eTime       = "";
            var qt          = 0;

            foreach (var serv in DataHolder.GetInstance().Services.Where(serv => serv.Id == aService.Id))
            {
                foreach (var times in serv.ServiceValues.Where(times => times.Property.Name == "initialtime"))
                {
                    iTime = times.Value;
                }
                foreach (var times in serv.ServiceValues.Where(times => times.Property.Name == "endtime"))
                {
                    eTime = times.Value;
                }
            }
            if (Convert.ToDateTime(iTime) < Convert.ToDateTime(initialTime) && Convert.ToDateTime(initialTime) > Convert.ToDateTime(eTime))
            {
                return(false);
            }
            foreach (var serv in DataHolder.GetInstance().Reservations.Where(serv => serv.Id == aService.Id))
            {
                foreach (var times in serv.ServiceValues.Where(times => times.Property.Name == "date"))
                {
                    if (date.Split(' ')[0] == times.Value.Split(' ')[0])
                    {
                        foreach (var ar in serv.ServiceValues.Where(ar => ar.Property.Name == "quantity"))
                        {
                            qt += Convert.ToInt32(ar.Value);
                        }
                    }
                }
            }
            aParam = new Memento(aParam);
            aParam.Add("qt", qt.ToString());
            return(_darthVader.CheckAvailability(aParam, aService));
        }
Exemplo n.º 8
0
 public Memento CreateSnapshot()
 {
     Memento result = new Memento();
     result.NodeType = "ShapeStyle";
     result["name"] = this.Name;
     result.Add(LineStyleInfo);
     result.Add(FillStyleInfo);
     result.Add(FontStyleInfo);
     return result;
 }
Exemplo n.º 9
0
 public Memento CreateSnapshot()
 {
     Memento result = new Memento();
     result.NodeType = "ShapeStyles";
     foreach (KeyValuePair<string, IShapeStyle> pair in StyleList)
     {
         Memento styleSnapshot = pair.Value.CreateSnapshot();
         styleSnapshot["name"] = pair.Key;
         result.Add(styleSnapshot);
     }
     return result;
 }