private bool SaveData() { bool isSuccessful = false; string display = string.Empty; bool isValid = ValidateValue(); if (isValid) { SaveInstanceData(); InstanceSavingEventArgs args = new InstanceSavingEventArgs(CurrentInstance); if (InstanceSaving != null) { InstanceSaving(this, args); } if (args.IsSuccessful) { //CurrentInstance = args.Instance; isSuccessful = true; display = Localize("Common.Subject.UI.InstanceEdit.SaveOK", "* Save OK."); } else { isSuccessful = false; display = Localize("Common.Subject.UI.InstanceEdit.SaveFailed", "* Save failed."); } } else { isSuccessful = false; display = Localize("Common.Subject.UI.InstanceEdit.InputInvalid", "* Input invalid."); } lbResultMsg.Text = display; return(isSuccessful); }
protected void ucIEdit_InstanceSaving(object sender, InstanceSavingEventArgs e) { ProductDto instance = e.Instance as ProductDto; if (instance != null) { using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { ProductFacade facade = new ProductFacade(uow); IFacadeUpdateResult <ProductData> result = facade.SaveProduct(instance); e.IsSuccessful = result.IsSuccessful; if (result.IsSuccessful) { // Refresh Instance CurrentInstance = result.ToDto <ProductDto>(new ProductConverter()); } else { // Deal with Update result ProcUpdateResult(result.ValidationResult, result.Exception); } } } }