Skip to content

Commit 75457af

Browse files
Correct user interactions
1 parent 3dc7964 commit 75457af

File tree

223 files changed

+1026
-209162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+1026
-209162
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,9 @@ FodyWeavers.xsd
396396

397397
# JetBrains Rider
398398
*.sln.iml
399+
400+
401+
402+
403+
404+
Database/

Blog(Dirty)/Blog(Dirty).csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
45
<OutputType>Exe</OutputType>
56
<TargetFramework>net8.0</TargetFramework>
67
<RootNamespace>Blog_Dirty_</RootNamespace>

Blog(Dirty)/BlogInterface.cs

Lines changed: 130 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Microsoft.VisualBasic.FileIO;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Runtime.CompilerServices;
@@ -14,9 +15,12 @@ namespace Blog_Dirty_
1415
/// </summary>
1516
sealed class BlogInterface
1617
{
17-
public BlogInterface()
18+
private PostsManager postsManager;
19+
private User user;
20+
public BlogInterface(User user)
1821
{
19-
22+
postsManager = new PostsManager();
23+
this.user = user;
2024
}
2125

2226
/// <summary>
@@ -48,7 +52,7 @@ public void writeBlogPost()
4852

4953
string blogName;
5054
bool exit = false;
51-
string blogData;
55+
string blogData = string.Empty;
5256

5357
Console.WriteLine();
5458

@@ -62,16 +66,30 @@ public void writeBlogPost()
6266

6367
while (!exit)
6468
{
69+
string addon = string.Empty;
6570
writerMode();
66-
blogData = Console.ReadLine();
71+
addon += Console.ReadLine();
6772

68-
if (blogData == "exit")
73+
if (addon == "exit")
6974
{
7075
exit = true;
76+
break;
7177
}
7278

79+
addon += " ";
80+
blogData += addon;
81+
7382
}
7483
defaultMode();
84+
85+
if (blogData != string.Empty)
86+
postsManager.addPost(user, blogName, blogData);
87+
else
88+
{
89+
throw new Exception("No Data in post");
90+
}
91+
92+
selectOption();
7593
}
7694
/// <summary>
7795
/// Outputs blog post
@@ -81,42 +99,138 @@ public void writeBlogPost()
8199
/// </returns>
82100
public void readBlogPost()
83101
{
102+
bool exit = false;
103+
string writerData = string.Empty;
104+
string blogName;
105+
106+
Console.WriteLine();
107+
84108
readerMode();
109+
110+
string[] postData = postsManager.searchForUserPosts(user.UserName);
85111

112+
foreach (string post in postData)
113+
{
114+
Console.WriteLine(post);
115+
}
86116

117+
/* writerMode();
118+
119+
while (!exit)
120+
{
121+
writerMode();
122+
123+
string addon = string.Empty;
124+
addon += Console.ReadLine();
125+
126+
if (addon == "exit")
127+
{
128+
exit = true;
129+
break;
130+
}
131+
132+
addon += " ";
133+
writerData = addon;
134+
}*/
87135

88136
defaultMode();
137+
selectOption();
89138
}
139+
90140
/// <summary>
91-
/// This method welcome our users
141+
/// This method makes user write two variables"
142+
/// <list type="table">
143+
/// <item><param name="blogName">The name of blog to read</item>
144+
/// <item><param name="username">The name of user who created blog</param></item>
145+
/// </list>
92146
/// </summary>
93-
public void menu()
147+
public void readSpecifiedBlogPost()
94148
{
95-
ConsoleKeyInfo option;
149+
bool exit = false;
150+
string writerData = string.Empty;
151+
string blogName;
152+
string username;
153+
string[] postData;
96154

97-
Console.WriteLine("Welcome in BlogApp!!!\n\n\n");
98155

156+
Console.WriteLine();
157+
Console.Write("Enter blog name: ");
158+
blogName = Console.ReadLine();
159+
Console.WriteLine("Enter username of creator: ");
160+
username = Console.ReadLine();
161+
162+
readerMode();
163+
164+
postData = postsManager.searchForUserPosts(user.UserName); //To be fixed
165+
166+
foreach (string post in postData)
167+
{
168+
Console.WriteLine(post);
169+
}
170+
171+
Console.WriteLine(postData);
172+
173+
writerMode();
174+
175+
while (!exit)
176+
{
177+
writerMode();
178+
179+
string addon = string.Empty;
180+
addon += Console.ReadLine();
181+
182+
if (addon == "exit")
183+
{
184+
exit = true;
185+
break;
186+
}
187+
188+
addon += " ";
189+
writerData = addon;
190+
}
191+
192+
defaultMode();
193+
selectOption();
194+
}
195+
/// <summary>
196+
/// selectOption make user choose what he want to do
197+
/// </summary>
198+
public void selectOption()
199+
{
200+
ConsoleKeyInfo option;
99201
Console.WriteLine("Select the option from below");
100202

101203
Console.WriteLine("a. Write a blog post");
102204
Console.WriteLine("b. Read your blog posts");
103-
Console.WriteLine("c. Read specified post");
205+
Console.WriteLine("d. Exit Program");
104206
Console.Write("Your option: ");
105207

106208
option = Console.ReadKey();
107209

108210
if (ConsoleKey.A == option.Key)
109211
{
110-
writeBlogPost();
212+
writeBlogPost();
111213
}
112-
else if(ConsoleKey.B == option.Key)
214+
else if (ConsoleKey.B == option.Key)
113215
{
114-
216+
readBlogPost();
115217
}
116-
else if(ConsoleKey.C == option.Key)
218+
else if (ConsoleKey.D == option.Key)
117219
{
118-
220+
return;
119221
}
120222
}
223+
224+
/// <summary>
225+
/// This method welcome our users
226+
/// </summary>
227+
public void menu()
228+
{
229+
ConsoleKeyInfo option;
230+
231+
Console.WriteLine("Welcome in BlogApp!!!\n\n\n");
232+
233+
selectOption();
234+
}
121235
}
122236
}

Blog(Dirty)/Posts.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@ namespace Blog_Dirty_
88
{
99
public class Posts
1010
{
11+
/// <summary>
12+
/// Class <c>Posts</c> represent post in application
13+
/// <list type="bullet">
14+
/// <item><param name="postName">name of the post</param></item>
15+
/// <item><param name="postData">stores the post data</param></item>
16+
/// </list>
17+
/// </summary>
1118
public Posts(string postName, string postData)
1219
{
1320
this.postName = postName;
1421
this.postData = postData;
1522
}
1623

24+
/// <summary>
25+
/// Gets or sets the name of the post
26+
/// </summary>
1727
public string postName { get; set; }
28+
/// <summary>
29+
/// Gets or sets the data of the post
30+
/// </summary>
1831
public string postData { get; set; }
32+
/// <summary>
33+
/// Gets or sets the owner of the post
34+
/// </summary>
1935
public string username { get; set; }
2036
}
2137
}

0 commit comments

Comments
 (0)