Ejemplo n.º 1
0
        public async Task <RedirectToPageResult> OnPostCropImageAsync(Guid?imageId, int selLeft, int selTop, int selWidth, int selHeight, double coefficient, Guid?recordId)
        {
            RecordId = recordId ?? Guid.Empty;
            ImageId  = imageId ?? Guid.Empty;

            if (selLeft >= 0 && selTop >= 0 && selWidth > 0 && selHeight > 0 && coefficient >= 1)
            {
                var rect = new Rectangle(selLeft, selTop, selWidth, selHeight);
                await _cropImageService.CropImage(ImageId, rect, coefficient);
            }

            return(RedirectToPage("Edit", new { ImageId, RecordId }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CropImage(CropImageDto cropImageDto)
        {
            try
            {
                var rect = new Rectangle(cropImageDto.Left, cropImageDto.Top, cropImageDto.Width, cropImageDto.Height);
                await _cropImageService.CropImage(cropImageDto.ImageId, rect, cropImageDto.Coefficient);

                return(Ok());
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }