Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge

  • Loading branch information...
commit 0a85a363188d353b2545f4ab4718f88b1adb25bd 2 parents 1e2ce14 + 2210e00
@Martikos Martikos authored
View
53 App_Code/DataServices/GarageDataService.cs
@@ -67,7 +67,10 @@ public static Garage addGarageSale(Garage gs)
}
public static Boolean deleteGarageSale(String id)
- {
+ {
+ Garage garage = getGarageSale(id);
+ ImageDataService.deleteImage(garage.imageId);
+
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("DELETE FROM GarageSale WHERE GarageID = @gid", conn);
@@ -82,18 +85,48 @@ public static Boolean updateGarageSale(String id, Garage newGarage)
{
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
- SqlCommand cmd = new SqlCommand("UPDATE GarageSale SET UserID = @userID, DateBegin = @DateBegin, DateEnd = @DateEnd, Address = @Address, Description = @Description", conn);
+ SqlCommand cmd = new SqlCommand("UPDATE GarageSale SET UserID = @userID, DateBegin = @DateBegin, DateEnd = @DateEnd, Address = @Address, Description = @Description, Image = @Image where GarageID = @GarageID", conn);
cmd.Parameters.AddWithValue("@userID", newGarage.userID);
cmd.Parameters.AddWithValue("@DateBegin", newGarage.DateBegin);
cmd.Parameters.AddWithValue("@DateEnd", newGarage.DateEnd);
cmd.Parameters.AddWithValue("@Address", newGarage.Address);
- cmd.Parameters.AddWithValue("@Description", newGarage.Description);
+ cmd.Parameters.AddWithValue("@Description", newGarage.Description);
+ cmd.Parameters.AddWithValue("@Image", newGarage.imageId);
+ cmd.Parameters.AddWithValue("@GarageId", newGarage.GarageID);
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
return (rowsAffected > 0);
- }
+ }
+
+ public static List<Garage> getGarageSalesBy(String columnName, String value, int limit = 0)
+ {
+ SqlConnection conn = DBConnector.getSqlConnection();
+ conn.Open();
+ SqlCommand cmd;
+ if (limit > 0)
+ {
+ cmd = new SqlCommand("SELECT TOP " + limit + " * FROM GarageSale where " + columnName + " = @Value", conn);
+ // cmd.Parameters.AddWithValue("@Limit", limit);
+ }
+ else
+ {
+ cmd = new SqlCommand("SELECT * FROM Listing where " + columnName + " = @Value", conn);
+ }
+ cmd.Parameters.AddWithValue("@Value", value);
+ SqlDataReader reader = cmd.ExecuteReader();
+ List<Garage> garageSales = new List<Garage>();
+ while (reader.Read())
+ {
+ Garage listing = extractGS(reader);
+ garageSales.Add(listing);
+ }
+ conn.Close();
+
+ return garageSales;
+ }
+
public static class ColumnNames
{
@@ -101,8 +134,9 @@ public static class ColumnNames
public static string UserId = "UserID";
public static string DateBegin = "DateBegin";
public static string DateEnd = "DateEnd";
- public static string Address = "Address";
- public static string Description = "Description";
+ public static string Address = "Address";
+ public static string Description = "Description";
+ public static string Image = "Image";
}
private static Garage extractGS(SqlDataReader reader)
{
@@ -112,7 +146,10 @@ private static Garage extractGS(SqlDataReader reader)
DateTime dateb = (DateTime)reader[ColumnNames.DateBegin];
DateTime datee = (DateTime)reader[ColumnNames.DateEnd];
string address = (string)reader[ColumnNames.Address];
- string description = (string)reader[ColumnNames.Description];
- return new Garage(userId, dateb, datee, address, description);
+ string description = (string)reader[ColumnNames.Description];
+ int imageid = (int)reader[ColumnNames.Image];
+ Garage garage = new Garage(uid, userId, dateb, datee, address, description);
+ garage.imageId = imageid;
+ return garage;
}
}
View
18 App_Code/DataServices/ImageDataService.cs
@@ -73,12 +73,16 @@ public static int addImage(Image fullImage, Image thumb)
public static Boolean deleteImage(int imageid)
{
- SqlConnection conn = DBConnector.getSqlConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("DELETE FROM Images WHERE ImageId = @ImageId", conn);
- cmd.Parameters.AddWithValue("@ImageId", imageid);
- int rowsAffected = cmd.ExecuteNonQuery();
- conn.Close();
- return (rowsAffected > 0);
+ if (imageid > 0)
+ {
+ SqlConnection conn = DBConnector.getSqlConnection();
+ conn.Open();
+ SqlCommand cmd = new SqlCommand("DELETE FROM Images WHERE ImageId = @ImageId", conn);
+ cmd.Parameters.AddWithValue("@ImageId", imageid);
+ int rowsAffected = cmd.ExecuteNonQuery();
+ conn.Close();
+ return (rowsAffected > 0);
+ }
+ return false;
}
}
View
11 App_Code/DataServices/ListingDataService.cs
@@ -102,6 +102,15 @@ public static Listing addListing(Listing listing)
public static Boolean deleteListing(String id)
{
+ Listing listing = getListing(id);
+ List<Tag> tags = TagDataService.getTagsFromListing(listing);
+ foreach (Tag tag in tags)
+ {
+ deleteListingTag(listing, tag);
+ }
+
+ ImageDataService.deleteImage(listing.imageId);
+
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("DELETE FROM Listing where ListingId = @ListingId", conn);
@@ -113,7 +122,7 @@ public static Boolean deleteListing(String id)
}
public static Boolean updateListing(String idToUpdate, Listing newListing)
- {
+ {
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("UPDATE Listing SET Title = @Title, Description = @Description, Price = @Price, Location = @Location, Date = @Date, Image = @Image WHERE ListingId = @ListingId", conn);
View
9 App_Code/DataServices/NetworkDataService.cs
@@ -93,8 +93,15 @@ public static Network addNetwork(Network network)
return network;
}
- public static Boolean deleteNetwork(String id)
+ public static Boolean deleteNetwork(int id)
{
+ Network network = getNetwork(id);
+ List<Guid> usersInNetwork = getUsersOfNetwork(network.id.ToString());
+ foreach (Guid userId in usersInNetwork)
+ {
+ UserDataService.removeUserFromNetwork(UserDataService .getUser(userId), network);
+ }
+
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("DELETE FROM Networks where NetworkId = @id", conn);
View
1  App_Code/DataServices/NotificationDataService.cs
@@ -68,6 +68,7 @@ public static List<Notification> getNotifications(String userId)
}
+
public static List<Notification> getConversation(String SenderId, String ReceiverId)
{
List<Notification> returnList = new List<Notification>();
View
11 App_Code/DataServices/TagDataService.cs
@@ -99,8 +99,17 @@ public static List<Tag> getTagsByName(string name)
return returnList;
}
- public static Boolean deleteTag(Tag tag)
+ public static Boolean deleteTag(int id)
{
+ Tag tag = getTag(id);
+ List<int> listingIds = ListingDataService.getListingOfTag(id.ToString());
+ foreach (int listingId in listingIds)
+ {
+ Listing listing = ListingDataService.getListing(listingId.ToString());
+ ListingDataService.deleteListingTag(listing, tag);
+ }
+
+
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("DELETE FROM Tags where TagId = @TagId", conn);
View
24 App_Code/DataServices/UserDataService.cs
@@ -45,9 +45,31 @@ public static bool addUser(User user)
public static bool deleteUser(Guid idToDelete)
{
+ User thisUser = getUser(idToDelete);
+ List<Network> networks = NetworkDataService.getNetworksOfUser(thisUser.uid.ToString());
+ foreach (Network network in networks) {
+ removeUserFromNetwork(thisUser, network);
+ }
+
+ List<Listing> listings = ListingDataService.getListingsBy(ListingDataService.ColumnNames.UserId, thisUser.uid.ToString());
+ foreach (Listing listing in listings)
+ {
+ ListingDataService.deleteListing(listing.ListingId.ToString());
+ }
+
+ List<Garage> garageSales = GarageDataService.getGarageSalesBy(GarageDataService.ColumnNames.UserId, thisUser.uid.ToString());
+ foreach (Garage garageSale in garageSales)
+ {
+ GarageDataService.deleteGarageSale(garageSale.GarageID.ToString());
+ }
+
+ //@ToDo Delete Notifications
+ ImageDataService.deleteImage(thisUser.imageId);
+
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
- SqlCommand cmd = new SqlCommand("DELETE FROM Users where UserId = @IdDelete", conn);
+ SqlCommand cmd = new SqlCommand("DELETE FROM Users WHERE UserId=@deleteId", conn);
+ cmd.Parameters.AddWithValue("@deleteId", idToDelete);
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
View
BIN  App_Data/Database.mdf
Binary file not shown
View
BIN  App_Data/Database_Log.ldf
Binary file not shown
View
4 Helpers/GetImage.ashx
@@ -7,8 +7,8 @@ using System.Data.SqlClient;
public class GetImage : IHttpHandler {
public void ProcessRequest (HttpContext context) {
- if (!string.IsNullOrEmpty(context.Request.QueryString["ID"]))
- {
+ if (!string.IsNullOrEmpty(context.Request.QueryString["ID"]) && context.Request.QueryString["ID"] != "0")
+ {
SqlConnection conn = DBConnector.getSqlConnection();
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT ContentType, Data FROM Images where ImageId = @ImageId", conn);
View
30 Helpers/GetThumbnail.ashx
@@ -7,22 +7,24 @@ using System.Data.SqlClient;
public class GetThumbnail : IHttpHandler {
public void ProcessRequest (HttpContext context) {
- if (string.IsNullOrEmpty(context.Request.QueryString["ID"])) throw new HttpException(400, "Bad Request: Missing ID");
- SqlConnection conn = DBConnector.getSqlConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("SELECT Thumbnail FROM Images where ImageId = @ImageId", conn);
- cmd.Parameters.AddWithValue("@ImageId", context.Request.QueryString["ID"]);
- SqlDataReader reader = cmd.ExecuteReader();
- if (reader.Read())
+ if (!string.IsNullOrEmpty(context.Request.QueryString["ID"]) && context.Request.QueryString["ID"] != "0")
{
- context.Response.ContentType = "image/jpg";
- context.Response.BinaryWrite((byte[])reader["Thumbnail"]);
+ SqlConnection conn = DBConnector.getSqlConnection();
+ conn.Open();
+ SqlCommand cmd = new SqlCommand("SELECT Thumbnail FROM Images where ImageId = @ImageId", conn);
+ cmd.Parameters.AddWithValue("@ImageId", context.Request.QueryString["ID"]);
+ SqlDataReader reader = cmd.ExecuteReader();
+ if (reader.Read())
+ {
+ context.Response.ContentType = "image/jpg";
+ context.Response.BinaryWrite((byte[])reader["Thumbnail"]);
+ }
+ else
+ {
+ context.Response.Write(HttpContext.Current.Server.MapPath("~/public/img/grey_wash_wall.png"));
+ context.Response.ContentType = "image/png";
+ }
}
- else
- {
- context.Response.Write(HttpContext.Current.Server.MapPath("~/public/img/grey_wash_wall.png"));
- context.Response.ContentType = "image/png";
- }
}
public bool IsReusable {
View
4 Views/Layout.master
@@ -89,7 +89,8 @@
<asp:LinkButton ID="nav_profile" runat="server" OnClick="go_profile">
<span class="nav_icon">l</span>
<span class="nav_text">Your Listings</span>
- </asp:LinkButton></li>
+ </asp:LinkButton>
+ </li>
<li>
<asp:LinkButton ID="nav_notifications" runat="server" OnClick="go_notifications">
<span class="nav_icon">h</span>
@@ -103,6 +104,7 @@
</asp:LinkButton>
</li>
+
</ul>
</nav>
</div>
View
49 Views/Layout.master.cs
@@ -3,7 +3,7 @@
using System.Linq;
using System.Web;
using System.Web.UI;
-using System.Web.UI.WebControls;
+using System.Web.UI.WebControls;
using System.Web.Security;
@@ -20,7 +20,6 @@ protected void search_query(object sender, EventArgs e)
String query = search_bar.Text.Trim();
Response.Redirect("~/Views/Search.aspx?query=" + query);
}
-
}
protected void go_search(object sender, EventArgs e)
{
@@ -32,40 +31,40 @@ protected void go_networks(object sender, EventArgs e)
}
protected void go_garage(object sender, EventArgs e)
{
- Response.Redirect("~/Views/Private/GarageSale.aspx");
+ Response.Redirect("~/Views/Private/GarageSale.aspx");
}
protected void go_post(object sender, EventArgs e)
{
Response.Redirect("~/Views/Private/Post.aspx");
}
protected void go_profile(object sender, EventArgs e)
- {
- if (HttpContext.Current.User.Identity.IsAuthenticated)
- {
- MembershipUser userInfo = Membership.GetUser();
- Guid userId = (Guid)userInfo.ProviderUserKey;
- Response.Redirect("~/Views/Search.aspx?user=" + userId.ToString());
- }
- else
- {
- Response.Redirect("~/Views/Login.aspx");
+ {
+ if (HttpContext.Current.User.Identity.IsAuthenticated)
+ {
+ MembershipUser userInfo = Membership.GetUser();
+ Guid userId = (Guid)userInfo.ProviderUserKey;
+ Response.Redirect("~/Views/Search.aspx?user=" + userId.ToString());
+ }
+ else
+ {
+ Response.Redirect("~/Views/Login.aspx");
}
}
protected void go_notifications(object sender, EventArgs e)
{
Response.Redirect("~/Views/Private/Notifications.aspx");
- }
-
- protected void LinkButton1_Click(object sender, EventArgs e)
- {
-
- }
- protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
- {
- FormsAuthentication.SignOut();
- Roles.DeleteCookie();
- Session.Clear();
- Response.Redirect("~/Views/Login.aspx");
+ }
+
+ protected void LinkButton1_Click(object sender, EventArgs e)
+ {
+
+ }
+ protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
+ {
+ FormsAuthentication.SignOut();
+ Roles.DeleteCookie();
+ Session.Clear();
+ Response.Redirect("~/Views/Login.aspx");
}
}
View
35 Views/Private/Admin.aspx
@@ -0,0 +1,35 @@
+<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Layout.master" AutoEventWireup="true" CodeFile="Admin.aspx.cs" Inherits="Views_Admin" %>
+
+<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
+ <script type = "text/javascript">
+
+ function showDiv() {
+ document.getElementById("div1").style.display = "none";
+ document.getElementById("div2").style.display = "none";
+ if (document.forms[0].rad1[0].checked) {
+ document.getElementById("div1").style.display = "block";
+ }
+ if (document.forms[0].rad1[1].checked) {
+ document.getElementById("div2").style.display = "block";
+ }
+ }
+ </script>
+ Hello Admin!<br /><br />
+ <div style="text-align:center"><span style="font-size: xx-large">This is the admin page!</span><br /><br /><br /></div>
+ <div id="query"; style="display:block; text-align:left">
+ Query User:<br />
+ <br />
+ <asp:TextBox ID="TextBox1" runat="server" Height="21px" Width="328px"></asp:TextBox>
+ &nbsp;
+ <br />
+ <br />
+ <asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="UserId" Width="201px"></asp:ListBox>
+ <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TomsListConnString %>" SelectCommand="SELECT [UserId], [Name] FROM [Users] WHERE [Name] = @username" DeleteCommand="DELETE FROM Users">
+ <SelectParameters>
+ <asp:ControlParameter ControlID="TextBox1" DefaultValue=" " Name="username" PropertyName="Text" />
+ </SelectParameters>
+ </asp:SqlDataSource>
+ <asp:Button ID="Deletebutton" runat="server" Text="Delete User" OnClick="Deletebutton_Click" />
+ <br /><br />
+ </div>
+</asp:Content>
View
45 Views/Private/Admin.aspx.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.Security;
+
+public partial class Views_Admin : System.Web.UI.Page
+{
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ Guid AspUserId = (Guid)Membership.GetUser().ProviderUserKey;
+ User user = UserDataService.getUser(AspUserId);
+
+ }
+ catch (System.NullReferenceException)
+ {
+ Response.Redirect("~/Views/Login.aspx");
+ }
+
+ }
+ protected void Deletebutton_Click(object sender, EventArgs e)
+ {
+ if (ListBox1.SelectedItem != null)
+ {
+ string name;
+ Guid userid;
+ try
+ {
+ name = ListBox1.SelectedItem.Text;
+ userid = (Guid)Membership.GetUser(name).ProviderUserKey;
+ Membership.DeleteUser(name, true);
+ UserDataService.deleteUser(userid);
+ ListBox1.DataBind();
+ }
+ catch (NullReferenceException ex)
+ {
+ Console.WriteLine("The ID does not exist. Did you hit the back button?");
+ }
+ }
+ }
+}
View
210 Views/Private/GarageSale.aspx.cs
@@ -4,78 +4,78 @@
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
-using System.Web.Security;
-using System.IO;
+using System.Web.Security;
+using System.IO;
using System.Drawing;
public partial class Views_Private_GarageSale : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
- {
- int[] hours = {12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
- if (!IsPostBack)
- {
- foreach (int i in hours) {
- for (int j = 0; j < 4; j++)
- {
- begin_time_list.Items.Add(i + ":" + (j*15).ToString().PadLeft(2,'0') + " AM");
- end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " AM");
- }
- }
- foreach (int i in hours)
- {
- for (int j = 0; j < 4; j++)
- {
- begin_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
- end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
- }
- }
- date_cal.SelectedDate = DateTime.Now;
- begin_time_list.SelectedIndex = 0;
- end_time_list.SelectedIndex = 0;
-
- }
+ {
+ int[] hours = {12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ if (!IsPostBack)
+ {
+ foreach (int i in hours) {
+ for (int j = 0; j < 4; j++)
+ {
+ begin_time_list.Items.Add(i + ":" + (j*15).ToString().PadLeft(2,'0') + " AM");
+ end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " AM");
+ }
+ }
+ foreach (int i in hours)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ begin_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
+ end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
+ }
+ }
+ date_cal.SelectedDate = DateTime.Now;
+ begin_time_list.SelectedIndex = 0;
+ end_time_list.SelectedIndex = 0;
+
+ }
}
protected void Button1_Click(object sender, EventArgs e)
{
- if (begin_time_list.SelectedIndex > 0
+ if (begin_time_list.SelectedIndex >= 0
&& date_cal.SelectedDate != null
- && end_time_list.SelectedIndex > 0
+ && end_time_list.SelectedIndex >= 0
&& textbox_location.Value != ""
&& textbox_description.Value != "")
{
try
- {
- string address = textbox_location.Value.ToString();
- string description = textbox_description.Value.ToString();
-
-
- DateTime begintime = date_cal.SelectedDate.Date + DateTime.Parse(begin_time_list.SelectedValue).TimeOfDay;
- DateTime endtime = date_cal.SelectedDate.Date + DateTime.Parse(end_time_list.SelectedValue).TimeOfDay;
-
- if (date_cal.SelectedDate.CompareTo(DateTime.Now) < 0) throw new InvalidDataException("You cannot create a garage sale in the past");
+ {
+ string address = textbox_location.Value.ToString();
+ string description = textbox_description.Value.ToString();
+
+
+ DateTime begintime = date_cal.SelectedDate.Date + DateTime.Parse(begin_time_list.SelectedValue).TimeOfDay;
+ DateTime endtime = date_cal.SelectedDate.Date + DateTime.Parse(end_time_list.SelectedValue).TimeOfDay;
+
+ if (date_cal.SelectedDate.CompareTo(DateTime.Now) < 0) throw new InvalidDataException("You cannot create a garage sale in the past");
if (endtime.CompareTo(begintime) <= 0) throw new InvalidDataException("End Time is before start time");
MembershipUser user = Membership.GetUser();
- Guid userId = (Guid)user.ProviderUserKey;
-
- Garage garageSale = new Garage(userId, begintime, endtime, address, description);
-
- if (imageUpload.HasFile)
- {
- int imageId = saveImageFile();
- garageSale.imageId = imageId;
- }
-
- garageSale = GarageDataService.addGarageSale(garageSale);
-
- textbox_description.Value = "";
- textbox_location.Value = "";
- begin_time_list.SelectedIndex = 0;
- end_time_list.SelectedIndex = 0;
- date_cal.SelectedDate = DateTime.Now;
-
- creategarage_output.Text = "Garage Sale created successfully!";
+ Guid userId = (Guid)user.ProviderUserKey;
+
+ Garage garageSale = new Garage(userId, begintime, endtime, address, description);
+
+ if (imageUpload.HasFile)
+ {
+ int imageId = saveImageFile();
+ garageSale.imageId = imageId;
+ }
+
+ garageSale = GarageDataService.addGarageSale(garageSale);
+
+ textbox_description.Value = "";
+ textbox_location.Value = "";
+ begin_time_list.SelectedIndex = 0;
+ end_time_list.SelectedIndex = 0;
+ date_cal.SelectedDate = DateTime.Now;
+
+ creategarage_output.Text = "Garage Sale created successfully!";
creategarage_output.Style.Add("color", "#00ff00");
}
catch (Exception ex)
@@ -98,54 +98,54 @@ protected void Button1_Click(object sender, EventArgs e)
}
}
- private int saveImageFile()
- {
- string ext = Path.GetExtension(imageUpload.PostedFile.FileName).ToLower();
- string contentType = "";
- switch (ext)
- {
- case ".jpg":
- case ".jpeg":
- contentType = "image/jpg";
- break;
- case ".png":
- contentType = "image/png";
- break;
- case ".gif":
- contentType = "image/gif";
- break;
- case ".bmp":
- contentType = "image/bmp";
- break;
- }
-
- Stream stream = imageUpload.PostedFile.InputStream;
- BinaryReader binReader = new BinaryReader(stream);
- byte[] data = binReader.ReadBytes(Convert.ToInt32(stream.Length));
- System.Drawing.Image temp = System.Drawing.Image.FromStream(stream);
- int width = (int)temp.Width;
- int height = (int)temp.Height;
- temp.Dispose();
-
- int thumbWidth = 100;
- int thumbHeight = thumbWidth * (int)((double)width / (double)height);
-
- System.Drawing.Image thumb = System.Drawing.Image.FromStream(stream);
- Bitmap tempThumb = new Bitmap(thumb, thumbWidth, thumbHeight);
- Graphics g = Graphics.FromImage(tempThumb);
- g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
- g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
- g.DrawImage(thumb, 0, 0, tempThumb.Width, tempThumb.Height);
- MemoryStream memStream = new MemoryStream();
- tempThumb.Save(memStream, System.Drawing.Imaging.ImageFormat.Jpeg);
- byte[] thumbData = memStream.ToArray();
-
- thumb.Dispose();
- tempThumb.Dispose();
- g.Dispose();
- Image fullImage = new Image(data, contentType, height, width);
- Image thumbImage = new Image(thumbData, "image/jpg", thumbHeight, thumbWidth);
- return ImageDataService.addImage(fullImage, thumbImage);
+ private int saveImageFile()
+ {
+ string ext = Path.GetExtension(imageUpload.PostedFile.FileName).ToLower();
+ string contentType = "";
+ switch (ext)
+ {
+ case ".jpg":
+ case ".jpeg":
+ contentType = "image/jpg";
+ break;
+ case ".png":
+ contentType = "image/png";
+ break;
+ case ".gif":
+ contentType = "image/gif";
+ break;
+ case ".bmp":
+ contentType = "image/bmp";
+ break;
+ }
+
+ Stream stream = imageUpload.PostedFile.InputStream;
+ BinaryReader binReader = new BinaryReader(stream);
+ byte[] data = binReader.ReadBytes(Convert.ToInt32(stream.Length));
+ System.Drawing.Image temp = System.Drawing.Image.FromStream(stream);
+ int width = (int)temp.Width;
+ int height = (int)temp.Height;
+ temp.Dispose();
+
+ int thumbWidth = 100;
+ int thumbHeight = thumbWidth * (int)((double)width / (double)height);
+
+ System.Drawing.Image thumb = System.Drawing.Image.FromStream(stream);
+ Bitmap tempThumb = new Bitmap(thumb, thumbWidth, thumbHeight);
+ Graphics g = Graphics.FromImage(tempThumb);
+ g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ g.DrawImage(thumb, 0, 0, tempThumb.Width, tempThumb.Height);
+ MemoryStream memStream = new MemoryStream();
+ tempThumb.Save(memStream, System.Drawing.Imaging.ImageFormat.Jpeg);
+ byte[] thumbData = memStream.ToArray();
+
+ thumb.Dispose();
+ tempThumb.Dispose();
+ g.Dispose();
+ Image fullImage = new Image(data, contentType, height, width);
+ Image thumbImage = new Image(thumbData, "image/jpg", thumbHeight, thumbWidth);
+ return ImageDataService.addImage(fullImage, thumbImage);
}
protected void Button1_Click1(object sender, EventArgs e)
{
@@ -184,5 +184,5 @@ private String createGarageDiv(Garage garage)
return objectHTML;
- }
+ }
}
View
13 Views/Private/Networks.aspx
@@ -2,9 +2,9 @@
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
- <table align="center">
+ <table>
<tr>
- <td style="width: 400px;">
+ <td>
Search For Networks<br />
<br />
<asp:TextBox ID="Network_Search" runat="server" ></asp:TextBox>
@@ -27,14 +27,11 @@
<br />
<asp:Label ID="ErrorMessage" runat="server"></asp:Label>
</td>
- <td style="width: 300px">
- <asp:Label ID="networklabel" runat="server" Text="Create Your Network"></asp:Label>
- <fieldset>
- <asp:Label ID="networklabel_name" class="form_label" runat="server" Text="Name"></asp:Label><asp:TextBox ID="addnetwork_name" runat="server" Visible="False"></asp:TextBox><br />
- <asp:Label ID="networklabel_pattern" class="form_label" runat="server" Text="Pattern"></asp:Label><asp:TextBox ID="addnetwork_pattern" runat="server" Visible="False"></asp:TextBox><br />
+ <td>
+ <asp:TextBox ID="addnetwork_name" runat="server" Visible="False"></asp:TextBox><br />
+ <asp:TextBox ID="addnetwork_pattern" runat="server" Visible="False"></asp:TextBox><br />
<asp:Label ID="addnetwork_label" runat="server" Text=""></asp:Label>
<asp:Button ID="addnetwork_button" runat="server" Text="Add Network" Visible="False" OnClick="addnetwork_button_Click" />
- </fieldset>
</td>
</tr>
</table>
View
3  Views/Private/Networks.aspx.cs
@@ -25,9 +25,6 @@ protected void Page_Load(object sender, EventArgs e)
addnetwork_name.Visible = true;
addnetwork_pattern.Visible = true;
addnetwork_button.Visible = true;
- networklabel.Visible = true;
- networklabel_name.Visible = true;
- networklabel_pattern.Visible = true;
}
}
}
View
15 Views/Private/Profile.aspx.cs
@@ -15,10 +15,17 @@ protected void Page_Load(object sender, EventArgs e)
Guid AspUserId = (Guid)Membership.GetUser().ProviderUserKey;
User user = UserDataService.getUser(AspUserId);
- name.Text = user.name;
- location.Text = user.location;
- email.Text = user.email;
- user_photo.ImageUrl = "~/Helpers/GetImage.ashx?ID=" + user.imageId;
+ if (user.name == "admin")
+ {
+ Response.Redirect("~/Views/Private/Admin.aspx");
+ }
+ else
+ {
+ name.Text = user.name;
+ location.Text = user.location;
+ email.Text = user.email;
+ user_photo.ImageUrl = "~/Helpers/GetImage.ashx?ID=" + user.imageId;
+ }
}
catch (System.NullReferenceException)
{
View
15 Views/Private/UpdatePost.aspx
@@ -14,6 +14,13 @@
document.getElementById('MainContent_image_preview').setAttribute('src', "../../Helpers/GetImage.ashx?ID=" + id);
}
}
+
+ function confirmDelete() {
+ if (confirm('Are you sure you want to Delete This Listing?')) {
+ var button = document.getElementById('MainContent_do_delete');
+ button.click();
+ }
+ }
</script>
<div id="form_item">
<table align="center">
@@ -32,7 +39,13 @@
<label for="Tags" class="form_label">Tags</label><asp:TextBox ID="textbox_tags" runat="server" name="Tags" class="form_field"></asp:TextBox><br /><br />
<label for="Image" class="form_label">Image (Optional)</label><asp:FileUpload ID="imageUpload" runat="server" onchange="changeImagePreview(this)"/><br /><br />
<asp:Label ID="addlisting_output" runat="server" Text=""></asp:Label><br />
- <label for="Tags" class="form_label"></label><asp:Button ID="button_post" runat="server" Text="Update Listing" class="form_button" OnClick="Update_Click"/>
+ <asp:Button ID="button_post" runat="server" Text="Update Listing" class="form_button" OnClick="Update_Click"/>
+ <br />
+ <br />
+ <button id="confirm_delete" runat="server" class="form_button" onclick="confirmDelete()">Delete Listing</button><br />
+ <div style="display: none">
+ <asp:Button ID="do_delete" runat="server" class="form_button" OnClick="do_delete_Click" />
+ </div>
</fieldset>
</td>
View
10 Views/Private/UpdatePost.aspx.cs
@@ -111,6 +111,7 @@ protected void Update_Click(object sender, EventArgs e)
addlisting_output.Text = "Listing updated successfully!";
addlisting_output.Style.Add("color", "#00ff00");
+ Response.Redirect("~/Views/Private/UpdatePost.aspx?L=" + oldListing.ListingId);
}
catch (Exception ex)
{
@@ -189,4 +190,13 @@ private int saveImageFile()
Image thumbImage = new Image(thumbData, "image/jpg", thumbHeight, thumbWidth);
return ImageDataService.addImage(fullImage, thumbImage);
}
+
+ protected void do_delete_Click(object sender, EventArgs e)
+ {
+ Listing listing = ListingDataService.getListing(Request.QueryString["L"]);
+ ImageDataService.deleteImage(listing.imageId);
+ ListingDataService.deleteListing(listing.ListingId.ToString());
+ Response.Redirect("~/Views/Search.aspx");
+
+ }
}
View
2  Views/Search.aspx
@@ -15,7 +15,7 @@
<table align="center">
<tr>
<td>
- <asp:Button ID="update_button" Text="Update Listing" runat="server" /><br /><br />
+ <asp:Button ID="update_button" Text="Update Listing" runat="server" OnClick="update_button_Click" /><br /><br />
<asp:Image ID="item_image" runat="server" Width="200" Height="200"/>
</td>
<td>
View
10 Views/Search.aspx.cs
@@ -186,10 +186,9 @@ private void getFeatured()
featured3_header.Text = "In Your Network";
networks.Visible = true;
networks_button.Visible = true;
- if (networks.Items.Count > 0)
- {
- getNetworkListings(networks.SelectedItem.Text);
- }
+
+ if(networks.SelectedIndex >= 0) getNetworkListings(networks.SelectedItem.Text);
+
}
else
{
@@ -363,7 +362,7 @@ private string createFeaturedItemDiv(Listing listing)
protected void networks_SelectedIndexChanged(object sender, EventArgs e)
{
-
+
}
@@ -378,4 +377,5 @@ protected void networks_button_Click(object sender, EventArgs e)
fr_view.ActiveViewIndex = 1;
getFeatured();
}
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.