public async Task <ActionResult> Edit(int?id) { OperationTypeViewModel vm = new OperationTypeViewModel(); if (id != null) { OperationTypeDto toGet = await _operationTypeRepo.Get(id.Value); if (toGet == null) { return(RedirectToAction("Index")); } vm = Mapper.Map <OperationTypeDto, OperationTypeViewModel>(toGet); } return(View(vm)); }
private OperationTypeDto GetClickedCategory(object sender) { //get button parent until we reach the user control (Editable Item Control) DependencyObject ucParent = ((Button)sender).Parent; while (!(ucParent is UserControl)) { ucParent = LogicalTreeHelper.GetParent(ucParent); } // cast to specific type from UserControl EditableItemControl userControl = (EditableItemControl)ucParent; //Get from Db the account with the id of the UserControl OperationTypeDto category = _operationTypeRepo.Get(userControl.Id); return(category); }