コード例 #1
0
        private void SubscribeToEvents()
        {
            categoriesDetailUC.SaveCategoriesDetailEventRaised += (sender, modelDictionary) =>
            {
                CategoriesDtoModel category = new CategoriesDtoModel()
                {
                    Id           = modelDictionary.ModelDictionary["Id"] == "" ? 0 : int.Parse(modelDictionary.ModelDictionary["Id"]),
                    Name         = modelDictionary.ModelDictionary["Name"],
                    SupplierId   = int.Parse(modelDictionary.ModelDictionary["SupplierId"]),
                    SupplierName = modelDictionary.ModelDictionary["SupplierName"],
                    Link         = modelDictionary.ModelDictionary["Link"],
                    Rate         = decimal.Parse(modelDictionary.ModelDictionary["Rate"]),
                    Notes        = modelDictionary.ModelDictionary["Notes"]
                };
                if (category.Id > 0)
                {
                    facade.UpdateCategory(category);
                }
                else
                {
                    facade.AddCategory(category);
                }

                EventHelper.RaiseEvent(this, SaveCategoryClickEventRaised, new EventArgs());
            };

            categoriesDetailUC.CancelCategoriesDetailEventRaised += (sender, e) => EventHelper.RaiseEvent(this, CancelClickEventRaised, new EventArgs());
        }