Skip to content

Commit f2fcafb

Browse files
committed
Implemented admin functionality for managing the uploaded images
1 parent fe6b05d commit f2fcafb

File tree

12 files changed

+162
-21
lines changed

12 files changed

+162
-21
lines changed

ProgrammersSpot/Business/ProgrammersSpot.Business.Services/UploadedImageService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public UploadedImageService(IRepository<UploadedImage> repo, IUnitOfWork uow)
2525

2626
public IQueryable<UploadedImage> GetAllImages()
2727
{
28-
return this.repo.All().OrderBy(i => i.DateUploaded);
28+
return this.repo.All().Where(i => !i.IsDeleted).OrderBy(i => i.DateUploaded);
2929
}
3030

3131
public IQueryable<UploadedImage> GetImagesWithTitle(string titleKeyword)
3232
{
33-
return this.repo.All().Where(i => i.Title.Contains(titleKeyword));
33+
return this.repo.All().Where(i => !i.IsDeleted && i.Title.Contains(titleKeyword));
3434
}
3535

3636
public UploadedImage GetImageById(int id)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<%@ Page Title="Manage images" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageImages.aspx.cs" Inherits="ProgrammersSpot.WebClient.Admin.ManageImages" %>
2+
3+
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
4+
<div class="manage-images">
5+
<asp:GridView ID="GridViewImages" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="PrgrammersSpotSqlDataSource" AllowPaging="True" AllowSorting="True" Width="1000px">
6+
<Columns>
7+
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
8+
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" >
9+
<ItemStyle VerticalAlign="Top" />
10+
</asp:BoundField>
11+
<asp:BoundField DataField="DateUploaded" HeaderText="DateUploaded" SortExpression="DateUploaded" ReadOnly="True" >
12+
<ItemStyle VerticalAlign="Top" />
13+
</asp:BoundField>
14+
<asp:ImageField DataImageUrlField="ThumbnailSrc" HeaderText="ThumbnailImg">
15+
<ControlStyle Height="300px" Width="300px" />
16+
<ItemStyle Width="300px" Wrap="False" />
17+
</asp:ImageField>
18+
<asp:ImageField DataImageUrlField="OriginalSrc" HeaderText="LargeImg">
19+
<ControlStyle Height="300px" Width="300px" />
20+
<ItemStyle Width="300px" />
21+
</asp:ImageField>
22+
<asp:BoundField DataField="UploaderId" HeaderText="UploaderId" SortExpression="UploaderId" ReadOnly="True" >
23+
<ItemStyle VerticalAlign="Top" />
24+
</asp:BoundField>
25+
<asp:BoundField DataField="LikesCount" HeaderText="LikesCount" SortExpression="LikesCount" >
26+
<ItemStyle VerticalAlign="Top" />
27+
</asp:BoundField>
28+
<asp:BoundField DataField="DislikesCount" HeaderText="DislikesCount" SortExpression="DislikesCount" >
29+
<ItemStyle VerticalAlign="Top" />
30+
</asp:BoundField>
31+
<asp:BoundField DataField="IsDeleted" HeaderText="IsDeleted" SortExpression="IsDeleted" />
32+
<asp:CommandField ShowEditButton="True">
33+
<ItemStyle VerticalAlign="Top" />
34+
</asp:CommandField>
35+
</Columns>
36+
<EditRowStyle Width="1000px" />
37+
<RowStyle Height="0px" VerticalAlign="Top" Width="1000px" />
38+
</asp:GridView>
39+
</div>
40+
<asp:SqlDataSource ID="PrgrammersSpotSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ProgrammersSpotDbConnectionString %>" SelectCommand="SELECT * FROM [UploadedImages] ORDER BY [DateUploaded] DESC" DeleteCommand="DELETE FROM [UploadedImages] WHERE [Id] = @original_Id" InsertCommand="INSERT INTO [UploadedImages] ([Title], [DateUploaded], [ThumbnailSrc], [OriginalSrc], [IsDeleted], [UploaderId], [LikesCount], [DislikesCount]) VALUES (@Title, @DateUploaded, @ThumbnailSrc, @OriginalSrc, @IsDeleted, @UploaderId, @LikesCount, @DislikesCount)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [UploadedImages] SET [Title] = @Title, [ThumbnailSrc] = @ThumbnailSrc, [OriginalSrc] = @OriginalSrc, [IsDeleted] = @IsDeleted, [LikesCount] = @LikesCount, [DislikesCount] = @DislikesCount WHERE [Id] = @original_Id">
41+
<DeleteParameters>
42+
<asp:Parameter Name="original_Id" Type="Int32" />
43+
</DeleteParameters>
44+
<InsertParameters>
45+
<asp:Parameter Name="Title" Type="String" />
46+
<asp:Parameter Name="DateUploaded" Type="DateTime" />
47+
<asp:Parameter Name="ThumbnailSrc" Type="String" />
48+
<asp:Parameter Name="OriginalSrc" Type="String" />
49+
<asp:Parameter Name="IsDeleted" Type="Boolean" />
50+
<asp:Parameter Name="UploaderId" Type="String" />
51+
<asp:Parameter Name="LikesCount" Type="Int32" />
52+
<asp:Parameter Name="DislikesCount" Type="Int32" />
53+
</InsertParameters>
54+
<UpdateParameters>
55+
<asp:Parameter Name="Title" Type="String" />
56+
<asp:Parameter Name="DateUploaded" Type="DateTime" />
57+
<asp:Parameter Name="ThumbnailSrc" Type="String" />
58+
<asp:Parameter Name="OriginalSrc" Type="String" />
59+
<asp:Parameter Name="IsDeleted" Type="Boolean" />
60+
<asp:Parameter Name="UploaderId" Type="String" />
61+
<asp:Parameter Name="LikesCount" Type="Int32" />
62+
<asp:Parameter Name="DislikesCount" Type="Int32" />
63+
<asp:Parameter Name="original_Id" Type="Int32" />
64+
</UpdateParameters>
65+
</asp:SqlDataSource>
66+
</asp:Content>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.UI;
6+
using System.Web.UI.WebControls;
7+
8+
namespace ProgrammersSpot.WebClient.Admin
9+
{
10+
public partial class ManageImages : System.Web.UI.Page
11+
{
12+
protected void Page_Load(object sender, EventArgs e)
13+
{
14+
15+
}
16+
}
17+
}

ProgrammersSpot/Clients/ProgrammersSpot.WebClient/Admin/ManageImages.aspx.designer.cs

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ProgrammersSpot/Clients/ProgrammersSpot.WebClient/Bundle.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<include path="~/Content/Site.css" />
66
<include path="~/Content/login.css" />
77
<include path="~/Content/takeabreak.css" />
8+
<include path="~/Content/admin.css" />
89
<include path="~/Content/main.css" />
910
<include path="~/Content/font-awesome.css" />
1011
<include path="~/Content/profile.css" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#MainContent_GridViewImages {
2+
margin-top: 80px;
3+
}

ProgrammersSpot/Clients/ProgrammersSpot.WebClient/Content/main.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,8 +2160,7 @@
21602160

21612161
table {
21622162
margin: 0 0 2em 0;
2163-
width: 100%;
2164-
}
2163+
}
21652164

21662165
table tbody tr {
21672166
border-style: solid;

ProgrammersSpot/Clients/ProgrammersSpot.WebClient/Content/takeabreak.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,15 @@
169169
background-image: url("Images/dislike-img.png")
170170
}
171171

172+
.image-details div.add-comment {
173+
margin-bottom: 20px;
174+
margin-top: 20px;
175+
}
176+
172177
.image-details textarea.add-comment {
173178
width: 600px;
174179
height: 100px;
175180
margin-right: 20px;
176-
margin-bottom: 20px;
177181
vertical-align:top;
178182
}
179183

ProgrammersSpot/Clients/ProgrammersSpot.WebClient/ProgrammersSpot.WebClient.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@
208208
<Content Include="Account\TwoFactorAuthenticationSignIn.aspx" />
209209
<Content Include="Account\UploadProfilePic.aspx" />
210210
<Content Include="Account\VerifyPhoneNumber.aspx" />
211+
<Content Include="Admin\ManageImages.aspx" />
212+
<Content Include="Content\admin.css" />
211213
<Content Include="Content\profiles-list.css" />
212214
<Content Include="Companies\Default.aspx" />
213215
<Content Include="Contact.aspx" />
@@ -418,6 +420,13 @@
418420
<Compile Include="Account\VerifyPhoneNumber.aspx.designer.cs">
419421
<DependentUpon>VerifyPhoneNumber.aspx</DependentUpon>
420422
</Compile>
423+
<Compile Include="Admin\ManageImages.aspx.cs">
424+
<DependentUpon>ManageImages.aspx</DependentUpon>
425+
<SubType>ASPXCodeBehind</SubType>
426+
</Compile>
427+
<Compile Include="Admin\ManageImages.aspx.designer.cs">
428+
<DependentUpon>ManageImages.aspx</DependentUpon>
429+
</Compile>
421430
<Compile Include="App_Start\BundleConfig.cs" />
422431
<Compile Include="About.aspx.cs">
423432
<DependentUpon>About.aspx</DependentUpon>

ProgrammersSpot/Clients/ProgrammersSpot.WebClient/Site.Master

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,7 @@
5858
<li><a runat="server" href="~/Programmers">Programmers</a></li>
5959
<li><a runat="server" href="~/TakeABreak">Take a break!</a></li>
6060
</ul>
61-
<asp:LoginView runat="server">
62-
<RoleGroups>
63-
<asp:RoleGroup Roles="Admin">
64-
<ContentTemplate>
65-
<ul class="nav navbar-nav navbar-right">
66-
<li><a runat="server" href="~/">Administration</a></li>
67-
</ul>
68-
</ContentTemplate>
69-
</asp:RoleGroup>
70-
</RoleGroups>
71-
</asp:LoginView>
61+
7262
<asp:LoginView runat="server" ViewStateMode="Disabled">
7363
<AnonymousTemplate>
7464
<ul class="nav navbar-nav navbar-right">
@@ -85,7 +75,23 @@
8575
</ul>
8676
</LoggedInTemplate>
8777
</asp:LoginView>
88-
78+
<asp:LoginView runat="server">
79+
<RoleGroups>
80+
<asp:RoleGroup Roles="Admin">
81+
<ContentTemplate>
82+
<ul class="nav navbar-nav navbar-right">
83+
<li>
84+
<ul class="nav navbar-nav navbar-right">
85+
<li><a runat="server" href="#">Manage users</a></li>
86+
<li><a runat="server" href="#">Manage companies</a></li>
87+
<li><a runat="server" href="~/Admin/ManageImages">Manage images</a></li>
88+
</ul>
89+
</li>
90+
</ul>
91+
</ContentTemplate>
92+
</asp:RoleGroup>
93+
</RoleGroups>
94+
</asp:LoginView>
8995
</div>
9096
</div>
9197
</div>

0 commit comments

Comments
 (0)