public async Task <ProductModel> GetProductByID(int id) { var product = await _database.Products.FindAsync(id); ProductModel model = _mapper.Map <ProductModel>(product); model.DesscriptionENG = await TranslateOperation.TranslateTextAsync(product.Description); return(model); }
public async Task <IEnumerable <ProductModel> > GetAllProducts() { var products = await _database.Products.ToListAsync(); List <ProductModel> productModels = new List <ProductModel>(); foreach (var product in products) { ProductModel model = _mapper.Map <ProductModel>(product); model.DesscriptionENG = await TranslateOperation.TranslateTextAsync(product.Description); productModels.Add(model); } return(productModels); }
public override void End() { if (Finished) { return; } var endX = Obj.X; var endY = Obj.Y; Obj.X = StartX; Obj.Y = StartY; Finished = true; var op = new TranslateOperation(Project, Obj, endX, endY); Project.ExecuteOp(op); base.End(); }
public override bool OnMouseMove(Point mouseCurPos, Point mousePrevPos, BaseViewport viewport) { if (viewport.ViewportType != BaseViewport.ViewportTypes.PERSPECTIVE) { UpdateCursor(mouseCurPos, viewport); if (viewport.IsButtonHeld(BaseViewport.ViewportButtons.LEFT)) { // set standard values Vector3 mouseDownPosition = new Vector3(mouseDownPos.X, mouseDownPos.Y, 0); Vector3 prevMousePosition = new Vector3(mousePrevPos.X, mousePrevPos.Y, 0); Vector3 currentMousePosition = new Vector3(mouseCurPos.X, mouseCurPos.Y, 0); Matrix4 fromGridSpaceMatrix = viewport.Camera.GetViewMatrix().ClearTranslation(); // we only give the rubberband volume if the mouse has moved in creation mode bool mouseHasMoved = (currentMousePosition - mouseDownPosition).Length > GeneralUtility.Epsilon; if (currentAction == SolidToolActionType.Create && mouseHasMoved) { mouseDownPosition.Z = -viewport.GridSize * 4; currentMousePosition.Z = viewport.GridSize * 4; } // convert to world mouseDownPosition = viewport.ViewportToWorld(mouseDownPosition); prevMousePosition = viewport.ViewportToWorld(prevMousePosition); currentMousePosition = viewport.ViewportToWorld(currentMousePosition); // snap Vector3 snappedDownMousePosition = GeneralUtility.SnapToGrid(mouseDownPosition, viewport.GridSize); Vector3 snappedPrevMousePosition = GeneralUtility.SnapToGrid(prevMousePosition, viewport.GridSize); Vector3 snappedCurrentMousePosition = GeneralUtility.SnapToGrid(currentMousePosition, viewport.GridSize); RubberBand rubberband = controller.RubberBand; switch (currentAction) { case SolidToolActionType.Create: rubberband.Bounds.Reset(); rubberband.Bounds.Grow(snappedDownMousePosition); rubberband.Bounds.Grow(snappedCurrentMousePosition); break; case SolidToolActionType.Drag: { Vector3 delta = snappedCurrentMousePosition - snappedPrevMousePosition; if (delta != Vector3.Zero) { TranslateOperation translate = new TranslateOperation(delta) { GridSize = viewport.GridSize, Transform = fromGridSpaceMatrix }; rubberband.PerformOperation(translate); rubberband.ShowGrabhandles = false; } } break; case SolidToolActionType.Transform: { SolidGrabHandles handles = rubberband.Handles; IMapObjectOperation operation = null; Vector3 delta = currentMousePosition - prevMousePosition; if (delta != Vector3.Zero) { rubberband.ShowGrabhandles = false; } switch (handles.Mode) { case SolidGrabHandles.HandleMode.Resize: operation = new ResizeTransformation(fromGridSpaceMatrix, snappedPrevMousePosition, snappedCurrentMousePosition, handles.LastHitStatus, viewport.GridSize); break; case SolidGrabHandles.HandleMode.Rotate: operation = new RotateTransformation(fromGridSpaceMatrix, mouseDownPosition, currentMousePosition, Matrix4.Identity); break; case SolidGrabHandles.HandleMode.Skew: operation = new SkewTransformation(fromGridSpaceMatrix, snappedDownMousePosition, snappedCurrentMousePosition, Matrix4.Identity, handles.LastHitStatus); break; } if (operation != null) { controller.RubberBand.PerformOperation(operation); } } break; } } } else { controller.SetCursor(Cursors.Default); } return(true); }