public async Task UpdateAuthor(ViewModel.AuthorModel item) { await DeleteAsync <Model.AuthorModel>(item.Slug).ContinueWith(async(results) => { await InsertAsync(new Model.AuthorModel { Slug = item.Slug, Bio = item.Bio, Description = item.Description, Hash = item.Hash, IsOrg = item.IsOrg, Name = item.Name, ProfileUrl = item.ProfileUrl, Uid = item.Uid, Best_answererIdDescription = item.Badge != null ? item.Badge.Best_answerer.Description : null, IdentityDescription = item.Badge != null ? item.Badge.Identity.Description : null }); }); await DeleteAsync <Model.AvatarModel>(item.Slug).ContinueWith(async(results1) => { await InsertAsync(new Model.AvatarModel { AuthorSlug = item.Slug, Id = item.Avatar.Id, Template = item.Avatar.Template, }); }); }
public async Task <ViewModel.AuthorModel> QueryAuthor(string slug) { var vAuthor = new ViewModel.AuthorModel(); var author = await Table <Model.AuthorModel>().Where(d => d.Slug == slug).FirstOrDefaultAsync(); if (author != null) { vAuthor = new ViewModel.AuthorModel() { Bio = author.Bio, Slug = author.Slug, Description = author.Description, Hash = author.Hash, IsOrg = author.IsOrg, Name = author.Name, ProfileUrl = author.ProfileUrl, Uid = author.Uid, Avatar = await QueryAvatar(author.Slug), Badge = new ViewModel.IdentityModel() { Best_answerer = author.Best_answererIdDescription != null ? new ViewModel.BestAnswererModel() { Description = author.Best_answererIdDescription, Topics = new List <int>() } : null, Identity = author.IdentityDescription != null ? new ViewModel.BestAnswererModel() { Description = author.IdentityDescription, Topics = new List <int>() } : null } }; } return(vAuthor); }