public static string Edit(TeamTypeDTO TeamType) { using (ArmyBaseContext db = new ArmyBaseContext()) { string error = null; var toModify = db.TeamTypes.Where(x => x.Id == TeamType.Id).FirstOrDefault(); toModify.Name = TeamType.Name; var context = new ValidationContext(toModify, null, null); var result = new List <ValidationResult>(); Validator.TryValidateObject(toModify, context, result, true); foreach (var x in result) { error = error + x.ErrorMessage + "\n"; } if (error == null) { db.SaveChanges(); } return(error); } }
public AddTeamTypeViewModel(TeamTypeDTO teamType) { IsEdit = true; ButtonLabel = "Edit"; this.toEdit = teamType; Type = teamType.Name; NotifyOfPropertyChange(() => Type); }
public void LoadModifyTeamTypePage(TeamTypeDTO teamType) { IWindowManager manager = new WindowManager(); AddTeamTypeViewModel modify = new AddTeamTypeViewModel(teamType); manager.ShowDialog(modify, null, null); Reload(); }
public static void Delete(TeamTypeDTO TeamType) { using (ArmyBaseContext db = new ArmyBaseContext()) { var toDelete = db.TeamTypes.Where(x => x.Id == TeamType.Id).FirstOrDefault(); toDelete.IsDisabled = true; db.SaveChanges(); } }
public void Delete(TeamTypeDTO teamType) { IWindowManager manager = new WindowManager(); DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel(); bool?showDialogResult = manager.ShowDialog(modify, null, null); if (showDialogResult != null && showDialogResult == true) { TeamTypeService.Delete(teamType); } Reload(); }