public async Task <Post_Image_Response> SaveAsync(Post_image post_Image) { try{ await post_Image_Repository.AddAsync(post_Image); await unit_Of_Work.CompleteAsync(); return(new Post_Image_Response(post_Image)); } catch (Exception ex) { return(new Post_Image_Response($"Error while saving post-image. Message:{ex.Message}")); } }
public async Task <Post_Image_Response> DeleteAsync(Post_image post_Image) { var isExist = await post_Image_Repository.FindByCompatibleKeyAsync(post_Image.Post_Id, post_Image.Image_Id); if (isExist == null) { return(new Post_Image_Response("Post-image doesn't exist!")); } try{ post_Image_Repository.Delete(isExist); await unit_Of_Work.CompleteAsync(); return(new Post_Image_Response(isExist)); } catch (Exception ex) { return(new Post_Image_Response($"Error with deleting post-image: {ex.Message}")); } }
public async Task <Post_Image_Response> UpdateAsync(Post_image post_Image) { var isExist = await post_Image_Repository.FindByCompatibleKeyAsync(post_Image.Post_Id, post_Image.Image_Id); if (isExist == null) { return(new Post_Image_Response("Post-image not found!")); } try { post_Image_Repository.Update(post_Image); await unit_Of_Work.CompleteAsync(); return(new Post_Image_Response(post_Image)); } catch (Exception ex) { return(new Post_Image_Response($"Error when updating post-image: {ex.Message}")); } }
public Post_Image_Response(bool success, string message, Post_image post_Image) : base(success, message) { this.post_Image = post_Image; }
public Post_Image_Response(Post_image post_Image) : this(true, string.Empty, post_Image) { }
public void Update(Post_image post_Image) { context.Post_Images.Update(post_Image); }
public void Delete(Post_image post_Image) { context.Post_Images.Remove(post_Image); }
public async Task AddAsync(Post_image post_Image) { await context.Post_Images.AddAsync(post_Image); }