internal IFacadeUpdateResult <SetupMenuData> SaveSetupMenu(SetupMenuDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <SetupMenuData> result = new FacadeUpdateResult <SetupMenuData>(); ISetupMenuService service = UnitOfWork.GetService <ISetupMenuService>(); SetupMenu instance = RetrieveOrNew <SetupMenuData, SetupMenu, ISetupMenuService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.ParentMenuId = dto.ParentMenuId; instance.MenuText = dto.MenuText; instance.Tooltip = dto.Tooltip; instance.NavigateUrl = dto.NavigateUrl; instance.Sort = dto.Sort; instance.MenuTypeId = dto.MenuTypeId; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <SetupMenuData>()); result.Merge(saveQuery); } return(result); }
private void RetrieveData() { using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { SetupMenuFacade facade = new SetupMenuFacade(uow); SetupMenuDto instance = facade.RetrieveOrNewSetupMenu(InstanceId); CurrentInstance = instance; ucIEdit.CurrentInstance = instance; } }
public IFacadeUpdateResult<SetupMenuData> SaveSetupMenu(SetupMenuDto dto) { UnitOfWork.BeginTransaction(); IFacadeUpdateResult<SetupMenuData> result = SetupMenuSystem.SaveSetupMenu(dto); if (result.IsSuccessful) { UnitOfWork.CommitTransaction(); } else { UnitOfWork.RollbackTransaction(); } return result; }
protected void ucIList_InstanceRowSaving(object sender, InstanceRowSavingEventArgs e) { using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { SetupMenuDto project = e.Instance as SetupMenuDto; SetupMenuFacade facade = new SetupMenuFacade(uow); IFacadeUpdateResult <SetupMenuData> result = facade.SaveSetupMenu(project); e.IsSuccessful = result.IsSuccessful; if (result.IsSuccessful) { // Refresh whole list CurrentInstances = facade.RetrieveAllSetupMenu(); // Refresh global cache } else { // Deal with Update result ProcUpdateResult(result.ValidationResult, result.Exception); } } }
protected void ucIEdit_InstanceSaving(object sender, InstanceSavingEventArgs e) { SetupMenuDto instance = e.Instance as SetupMenuDto; if (instance != null) { using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey)) { SetupMenuFacade facade = new SetupMenuFacade(uow); IFacadeUpdateResult <SetupMenuData> result = facade.SaveSetupMenu(instance); e.IsSuccessful = result.IsSuccessful; if (result.IsSuccessful) { // Refresh Instance CurrentInstance = result.ToDto <SetupMenuDto>(new SetupMenuConverter()); } else { // Deal with Update result ProcUpdateResult(result.ValidationResult, result.Exception); } } } }