public static TModel FromAuthorAvatar <TModel>(AuthorAvatar authorAvatar) where TModel : AuthorAvatarApiModel, new() { var model = new TModel(); model.Id = authorAvatar.Id; return(model); }
public static string GetImageLocalUrl(this AuthorAvatar avatar) { if (string.IsNullOrWhiteSpace(avatar.Name)) { return(AppConstants.VirtualPaths.ImagePlaceholder.Substring(1)); } var url = VirtualPathUtility.Combine(AppConstants.VirtualPaths.AuthorsContent, avatar.Name).Substring(1); return(url); }
public async Task <AddOrUpdateAuthorAvatarResponse> Handle(AddOrUpdateAuthorAvatarRequest request) { var entity = await _dataContext.AuthorAvatars .SingleOrDefaultAsync(x => x.Id == request.AuthorAvatar.Id && x.IsDeleted == false); if (entity == null) { _dataContext.AuthorAvatars.Add(entity = new AuthorAvatar()); } entity.Name = request.AuthorAvatar.Name; await _dataContext.SaveChangesAsync(); return(new AddOrUpdateAuthorAvatarResponse() { }); }
public static AuthorAvatarApiModel FromAuthorAvatar(AuthorAvatar authorAvatar) => FromAuthorAvatar <AuthorAvatarApiModel>(authorAvatar);
public Author() { Social = new Social(); Badge = new AuthorBadge(); Avatar = new AuthorAvatar(); }
public Author() { Social = new Social(); Badge = new AuthorBadge(); Avatar = new AuthorAvatar(); }