-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API - refactoring with save picture on the product / add new method -…
… update picture
- Loading branch information
1 parent
236a5e6
commit c5b649a
Showing
10 changed files
with
96 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/API/Grand.Api/Commands/Handlers/Common/UpdatePictureCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Grand.Business.Storage.Interfaces; | ||
using MediatR; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Grand.Api.Commands.Models.Catalog | ||
{ | ||
public class UpdatePictureCommandHandler : IRequestHandler<UpdatePictureCommand, bool> | ||
{ | ||
private readonly IPictureService _pictureService; | ||
|
||
public UpdatePictureCommandHandler( | ||
IPictureService pictureService) | ||
{ | ||
_pictureService = pictureService; | ||
} | ||
|
||
public async Task<bool> Handle(UpdatePictureCommand request, CancellationToken cancellationToken) | ||
{ | ||
var picture = await _pictureService.GetPictureById(request.Model.Id); | ||
if (picture == null) | ||
return false; | ||
|
||
await _pictureService.UpdatePicture(picture.Id, request.Model.PictureBinary, | ||
request.Model.MimeType, request.Model.SeoFilename, request.Model.AltAttribute, request.Model.TitleAttribute); | ||
|
||
return true; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/API/Grand.Api/Commands/Models/Common/UpdatePictureCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Grand.Api.DTOs.Common; | ||
using MediatR; | ||
|
||
namespace Grand.Api.Commands.Models.Catalog | ||
{ | ||
public class UpdatePictureCommand : IRequest<bool> | ||
{ | ||
public PictureDto Model { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters