protected void Page_Load(object sender, EventArgs e) { user = (User)Session[Constants.Session_CurrentUser]; UserRateditem = (UserRatedClothes)Session[Constants.Session_CurrentUserRatedItem]; if (!PagePermissions.IsAllowedOnPage(this, user)) { Response.Redirect(PagePermissions.TransferToPage(this, user)); } //Update item properties if (!IsPostBack) { rItemRating.CurrentRating = UserRateditem.Rating; tbPrice.Text = UserRateditem.Price.ToString(); tbStore.Text = UserRateditem.Store_or_Link; tbComment.Text = UserRateditem.Comments; tbPhotoURL.Text = UserRateditem.PhotoURL; } }
/// <summary> /// The intent of this is to help keep the DB clean. When a user removes a item from their closet we'll try to remove it from the DB /// </summary> /// <param name=""></param> public static void Remove(UserRatedClothes item) { switch (item.ItemType) { case Type.Top: { TopModel topModel = new TopModel(); topModel.TryRemovingTop(item.ID); break; } case Type.Bottom: { break; } default: { break; } } }
protected void btnAddItem_Click(object sender, EventArgs e) { string designerName = tbDesignerName.Text; string neckSize = tbNeckSize.Text; string sleeveSize = tbSleeveSize.Text; string chestSize = tbChestSize.Text; //Determins if we try to add a shirt or not Boolean illegalArgument = false; if (String.IsNullOrEmpty(designerName)) { illegalArgument = true; lblInvalidDesignerName.Visible = true; } if (String.IsNullOrEmpty(neckSize)) { illegalArgument = true; lblInvalidNeckSize.Visible = true; } if (String.IsNullOrEmpty(sleeveSize)) { illegalArgument = true; lblInvalidSleeveSize.Visible = true; } if (String.IsNullOrEmpty(chestSize)) { //illegalArgument = true; //lblInvalidChestSize.Visible = true; } if (!illegalArgument) { //Make sure the inputs are correct DataBaseResults result = Top.Create(tbDesignerName.Text, tbNeckSize.Text, tbSleeveSize.Text, tbChestSize.Text, user.ID); if (result.ItemIDExists) { //TODO the next to lines should be placed in stage 4 of clothes model rating UserRatedClothes item = new UserRatedClothes(Clothes.Type.Top, result.ID, 0); //We have to add the item to the users closet to ensure that our Top DB and User validation stay in sync if (UserModel.TryAddingClosetItem(user, item)) { //newly added Top.ValidatedClosetItem(item.ID); } else { //user already owns the item item = user.GetClosetItemById(item.ID); } Session[Constants.Session_CurrentUserRatedItem] = item; Response.Redirect(Constants.Page_RateItem); } else { lblTroubleAddingItem.Visible = true; } } }