public async Task ModifyPostAsync(int id, PostDto dto) { var post = Database.Posts.Find(id); if (post == null) { return; } dto.FillModel(ref post); Database.Posts.Update(post); await Database.SaveAsync(); }
public async Task CreatePostAsync(PostDto dto) { Post post = null; dto.FillModel(ref post); var user = Database.Users.Get(dto.User.UserName); if (user is ApplicationUser) { post.User = user as ApplicationUser; } Database.Posts.Add(post); await Database.SaveAsync(); }