private void BtnSaveCategory_Click(object sender, RoutedEventArgs e) { OperationTypeDto operationTypeDto = new OperationTypeDto(); operationTypeDto.Name = tbCategoryName.Text; if (rbExpense.IsChecked == true) { operationTypeDto.IsCredit = false; } if (rbIncome.IsChecked == true) { operationTypeDto.IsCredit = true; } if (Id == null) { _operationTypeRepo.Add(operationTypeDto); } else { operationTypeDto.Id = Id.Value; _operationTypeRepo.Update(operationTypeDto); } this.Close(); }
public async Task <ActionResult> Edit(OperationTypeViewModel vm) { if (!ModelState.IsValid) { return(View(vm)); } OperationTypeDto dto = Mapper.Map <OperationTypeViewModel, OperationTypeDto>(vm); if (vm.Id == 0) { await _operationTypeRepo.Add(dto); } else { await _operationTypeRepo.Update(dto); } return(RedirectToAction("Index")); }