public IActionResult DeleteComponentType(EditComponentTypeViewModel viewModel) { //TODO: Deletet ComponentType ind database // var categoryComponentTypeInDb = // _unitOfWork.CategoryComponentTypes.SingleOrDefault(viewModel.Category.CategoryId); // _unitOfWork.CategoryComponentTypes.Remove(categoryComponentTypeInDb); var componentTypeInDb = _unitOfWork.ComponentTypes.Get(viewModel.ComponentType.ComponentTypeId); _unitOfWork.ComponentTypes.Remove(componentTypeInDb); _unitOfWork.Complete(); return(RedirectToAction("ComponentTypes", "ComponentType", new { id = viewModel.Category.CategoryId })); }
//Edit public IActionResult EditComponentType(int componentTypeId, int categoryId) { //TODO Make Async!! //var category = CategoryMock.GetCategories().SingleOrDefault(c => c.CategoryId == categoryId); // var componentType = ComponentTypeMock.GetComponentTypes().SingleOrDefault(c => c.ComponentTypeId == componentTypeId); var componentType = _unitOfWork.ComponentTypes.SingleOrDefault(c => c.ComponentTypeId == componentTypeId); var category = _unitOfWork.Categories.SingleOrDefault(c => c.CategoryId == categoryId); var viewModel = new EditComponentTypeViewModel() { Category = category, ComponentType = componentType }; return(View(viewModel)); }