예제 #1
0
        public async Task <Post_Type_Response> SaveAsync(Post_type post_Type)
        {
            try{
                await post_Type_Repository.AddAsync(post_Type);

                await unit_Of_Work.CompleteAsync();

                return(new Post_Type_Response(post_Type));
            }
            catch (Exception ex) {
                return(new Post_Type_Response($"Error while saving post-type. Message:{ex.Message}"));
            }
        }
예제 #2
0
        public async Task <Post_Type_Response> UpdateAsync(Post_type post_Type)
        {
            var isExist = await post_Type_Repository.FindByIdAsync(post_Type.Id);

            if (isExist == null)
            {
                return(new Post_Type_Response("Post type not found!"));
            }
            try
            {
                post_Type_Repository.Update(post_Type);
                await unit_Of_Work.CompleteAsync();

                return(new Post_Type_Response(post_Type));
            }
            catch (Exception ex)
            {
                return(new Post_Type_Response($"Error when updating post type: {ex.Message}"));
            }
        }
예제 #3
0
 public void Update(Post_type post_Type)
 {
     context.Post_Types.Update(post_Type);
 }
예제 #4
0
 public void Delete(Post_type post_Type)
 {
     context.Post_Types.Remove(post_Type);
 }
예제 #5
0
 public async Task AddAsync(Post_type post_Type)
 {
     await context.Post_Types.AddAsync(post_Type);
 }
예제 #6
0
 public Post_Type_Response(bool success, string message, Post_type post_Type) : base(success, message)
 {
     this.post_Type = post_Type;
 }
예제 #7
0
 public Post_Type_Response(Post_type post_Type) : this(true, string.Empty, post_Type)
 {
 }