/// <summary> /// Removes the specified slide. /// </summary> /// <param name="item"></param> public override void Remove(Slide item) { Check.NotNull(item, nameof(item)); RemoveFromDom(item.Number); _sdkPrePart.Presentation.Save(); CollectionItems.Remove(item); UpdateNumbers(); }
protected override void OnDelete(MedicalPractice entity) { if (entity == null) { return; } var associatedPhysicians = new List <string>(); using (var session = DataserviceProvider.SessionFactory.OpenSession()) { associatedPhysicians = session.Query <Monahrq.Infrastructure.Domain.Physicians.PhysicianMedicalPractice>() .Where(x => x.MedicalPractice.Id == entity.Id && !x.Physician.IsDeleted) .Select(x => string.Format(" - {0} {1} (NPI: {2})", x.Physician.FirstName, x.Physician.LastName, x.Physician.Npi)) .ToList(); } if (associatedPhysicians.Any()) { // string physicianNames = string.Join(",", associatedPhysicians); var warningMessage = string.Format("Unable to delete medical practice \"{0}\" because it is associated with the following physicians:", entity.Name) + Environment.NewLine; associatedPhysicians.ForEach(x => warningMessage += Environment.NewLine + x); MessageBox.Show(warningMessage, "Dataset Deletion Warning", MessageBoxButtons.OK); return; } else if (MessageBox.Show(string.Format(@"Are you sure want to delete {0} ?", entity.Name), @"Delete Confirmation", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } using (var session = DataserviceProvider.SessionFactory.OpenSession()) { using (var trans = session.BeginTransaction()) { var msg = string.Format("{0} {1} has been deleted.", entity.Name, Inflector.Titleize(entity.GetType().Name)); try { session.Evict(entity); session.Delete(entity); trans.Commit(); Notify(msg); } catch (Exception exc) { trans.Rollback(); var excToUse = exc; LogEntityError(excToUse, entity.GetType(), entity.Name); } } } CollectionItems.Remove(entity); }
/// <summary> /// Removes the specified table row. /// </summary> /// <param name="item"></param> public override void Remove(RowEx item) { if (!_innerSdkDic.ContainsKey(item)) { throw new ArgumentNullException(nameof(item)); } _innerSdkDic[item].Remove(); CollectionItems.Remove(item); }
public override void Remove(Slide innerRow) { //TODO: validate case when last slide is deleted Check.NotNull(innerRow, nameof(innerRow)); RemoveFromDom(innerRow.Number); _sdkPre.PresentationPart.Presentation.Save(); // save the modified presentation CollectionItems.Remove(innerRow); UpdateNumbers(); }
private void DeleteCurrentCollectionItem() { if (!Dialog.AskForDelete()) { return; } var itemToDelete = SelectedCollectionItem; SelectedCollectionItem = CollectionItems.Last(); OnPropertyChanged(nameof(SelectedCollectionItem)); _viewProvider.DeleteCollectionItem(itemToDelete.InnerObject.Id); CollectionItems.Remove(itemToDelete); }
protected override void OnDelete(MonahrqRegion entity) { if (entity == null) { return; } if (MessageBox.Show(string.Format("Delete Region: {0}", entity.Name), "Delete Region?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) { return; } if (entity.HospitalCount > 0) { MessageBox.Show( string.Format("Please delete associations with hospitals before deleting region \"{0}\". There are currently {1} hospital(s) associated with this region.", entity.Name, entity.HospitalCount), "Delete Region?", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.No); return; } using (var session = DataserviceProvider.SessionFactory.OpenSession()) { using (var trans = session.BeginTransaction()) { var updateQuery = string.Format(@"UPDATE {0} SET {1}_Id = NULL WHERE {1}_Id = {2} AND IsDeleted = 1", typeof(Hospital).EntityTableName(), entity.GetType().Name, entity.Id); session.CreateSQLQuery(updateQuery).ExecuteUpdate(); session.Flush(); trans.Commit(); } } CollectionItems.Remove(entity); base.OnDelete(entity); CollectionItems.Refresh(); MappedCustomRegionToPopulationCount = Service.GetCustomRegionToPopulationMappingCount(ConfigurationService.HospitalRegion.DefaultStates.OfType <string>().ToList()); }
/// <summary> /// Called when [delete]. /// </summary> /// <param name="entity">The entity.</param> protected override async void OnDelete(db.Physician entity) { if (entity == null) { return; } var result = MessageBox.Show(@"Are you sure want to delete the data for this physician, """ + entity.Name + @"""?", @"Delete Confirmation", MessageBoxButtons.OKCancel); if (result != DialogResult.OK) { return; } var errorOccurred = false; Exception errorException = null; var progressService = new ProgressService(); progressService.SetProgress("Deleting physican", 0, false, true); //await Task.Delay(500); string entityName = entity.Name; var executedSuccessully = await progressService.Execute(() => { using (var session = DataserviceProvider.SessionFactory.OpenSession()) { using (var trans = session.BeginTransaction()) { try { var updateQuery = string.Format(@"UPDATE {0} SET IsDeleted = 1 WHERE Id = {1} AND IsDeleted = 0", typeof(db.Physician).EntityTableName(), entity.Id); session.CreateSQLQuery(updateQuery).ExecuteUpdate(); session.Flush(); trans.Commit(); } catch { trans.Rollback(); throw; } } } }, opResult => { if (!opResult.Status && opResult.Exception != null) { errorOccurred = true; errorException = opResult.Exception; } else { errorOccurred = true; } }, new CancellationToken()); progressService.SetProgress("Completed", 100, true, false); if (errorOccurred && errorException != null) { Logger.Write(errorException, "Error deleting physician \"{0}\"", entity.Name); LogEntityError(errorException, typeof(db.Physician), entityName); return; } CollectionItems.Remove(entity); CollectionItems.Refresh(); Notify(string.Format("{0} {1} has been deleted.", entityName, Inflector.Titleize(typeof(db.Physician).Name))); }