Exemplo n.º 1
0
        void ProcessDeleteCommand(string[] items)
        {
            // load all shipping options
            ShippingMethodDto dto = ShippingManager.GetShippingMethods(null, true);

            if (dto != null && dto.ShippingOption.Count > 0)
            {
                // delete selected
                for (int i = 0; i < items.Length; i++)
                {
                    string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]);
                    if (keys != null)
                    {
                        Guid id = new Guid(keys[0]);

                        // delete selected shipping option

                        ShippingMethodDto.ShippingOptionRow[] soRows = (ShippingMethodDto.ShippingOptionRow[])dto.ShippingOption.Select(String.Format("ShippingOptionId='{0}'", id));
                        if (soRows != null && soRows.Length > 0)
                        {
                            soRows[0].Delete();
                        }
                    }
                }

                if (dto.HasChanges())
                {
                    ShippingManager.SaveShipping(dto);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            ShippingMethodDto sm = null;

            if (ShippingOptionId != Guid.Empty)
            {
                sm = (ShippingMethodDto)Session[GetShippingMethodSessionKey()];
            }

            if (sm == null && ShippingOptionId != Guid.Empty)
            {
                sm = ShippingManager.GetShippingOption(ShippingOptionId, true);
            }

            CreateEmptyDto(ref sm, true);

            IDictionary dic = new ListDictionary();

            dic.Add(_ShippingMethodDtoString, sm);

            ViewControl.SaveChanges(dic);

            // save changes
            if (sm.HasChanges())
            {
                ShippingManager.SaveShipping(sm);
            }

            ViewControl.CommitChanges(dic);

            // we don't need to store Dto in session any more
            Session.Remove(GetShippingMethodSessionKey());
        }