Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                long eventId;
                try
                {
                    eventId = Convert.ToInt64(Request.Params.Get("eventId"));
                }
                catch (ArgumentNullException)
                {
                    //Hacer un redirect a los grupos
                    eventId = 0;
                }

                if (eventId != 0)
                {
                    ViewState["eventId"] = eventId;
                    IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                    IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

                    HttpCookie           cookie      = Request.Cookies["loginName"];
                    List <DTOGroupsUser> groupsUsers = recommendationGroupService.ShowUserGroups(cookie.Value);

                    if (groupsUsers.Count == 0)
                    {
                        this.lblEvents.Visible               = false;
                        lclRecommendation.Visible            = false;
                        txtRecommend.Visible                 = false;
                        lblNoGroupsToRecommend.Visible       = true;
                        lblSelectCheckBox.Visible            = false;
                        this.btnCreateRecommendation.Visible = false;
                        return;
                    }

                    DataTable table = new DataTable();
                    using (var reader = ObjectReader.Create(groupsUsers, "group_usersId", "gr_name"))
                    {
                        table.Load(reader);
                    }
                    ViewState["groupsRecommend"] = table;
                    this.gvGroups.DataSource     = (DataTable)ViewState["groupsRecommend"];
                    this.DataBind();
                    this.gvGroups.Columns[0].Visible = false;
                }
                else
                {
                    lblNoeventId.Visible            = true;
                    txtRecommend.Visible            = false;
                    btnCreateRecommendation.Visible = false;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IIoCManager ioCManager = (IIoCManager)Application["managerIoC"];

                ISportEventService sportEventService = ioCManager.Resolve <ISportEventService>();

                List <string> categories = sportEventService.GetCategories();

                UpdateComboCategories(categories);
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = (IProductService)iocManager.Resolve <IProductService>();
            IOrderService   orderService   = (IOrderService)iocManager.Resolve <IOrderService>();

            //Cogemos los keywords
            long orderId = (long)Convert.ToInt32(Request.Params.Get("orderId"));
            List <ProductDetails> products = productService.GetOrderLineProductsByOrderId(orderId);
            double prize = 0;

            for (int i = 0; i < products.Count; i++)
            {
                prize += products.ElementAt(i).numberOfUnits *products.ElementAt(i).prize;
            }
            gvOrderDetails.DataSource = products;
            gvOrderDetails.DataBind();
            txtPrize.Text = prize.ToString();
            OrderDetails order = orderService.FindOrder(orderId);

            txtCard.Text          = order.CardNumber;
            txtPostalAddress.Text = order.PostalAddress.ToString();
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            long eventId;

            try
            {
                eventId = Convert.ToInt64(Request.Params.Get("eventId"));
            }
            catch (ArgumentNullException)
            {
                eventId = 0;
                lblNoComments.Visible = true;
                lblComments.Visible   = false;
                return;
            }
            int count;

            IIoCManager        ioCManager        = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            ISportEventService sportEventService = ioCManager.Resolve <ISportEventService>();

            count = Settings.Default.PracticaMaD_defaultCount;

            List <DTOComment> comments = sportEventService.FindComments(eventId, 0, count);

            if (comments.Count == 0)
            {
                lblNoComments.Visible = true;
                lblComments.Visible   = false;
                return;
            }
            else
            {
                lblComments.Visible = true;
            }

            DataTable table = new DataTable();

            using (var reader = ObjectReader.Create(comments, "commentId", "loginName", "eventId", "comment_description", "publishDate"))
            {
                table.Load(reader);
            }

            ViewState["comments"]      = table;
            this.gvComments.DataSource = table;
            this.DataBind();

            this.gvComments.Columns[0].Visible = false;
            this.gvComments.Columns[2].Visible = false;
        }
        protected void BtnDelete_Click(object sender, EventArgs e)
        {
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = iocManager.Resolve <IProductService>();

            long productId = long.Parse(btnDelete.Attributes["name"]);

            long id = Convert.ToInt64(cellOwnCommentId.Text);

            productService.DeleteComment(id);


            Response.Redirect(Response.
                              ApplyAppPathModifier("~/Pages/Product/ProductComments.aspx" + "?product=" + productId));
        }
        protected void btnDeleteTag_Click(object sender, EventArgs e)
        {
            long        tagId      = Convert.ToInt32(Request.Params.Get("tagId"));
            IIoCManager iocManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            ITagDao     tagDao     = (ITagDao)iocManager.Resolve <ITagDao>();

            if (SessionManager.IsUserAuthenticated(Context))
            {
                tagDao.Remove(tagId);
                Response.Redirect(Response.ApplyAppPathModifier("~/Pages/MainPage.aspx"));
            }
            else
            {
                lblAutenticated.Visible = true;
            }
        }
        protected void BtnEditCommentClick(object sender, EventArgs e)
        {
            if (commentBody.Text == string.Empty)
            {
                return;
            }

            if (SessionManager.IsUserAuthenticated(Context))
            {
                long commentId = long.Parse(Request.Params.Get("comment"));
                /* Get the Service */
                IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IProductService productService = iocManager.Resolve <IProductService>();

                string savedTags = (string)ViewState["tags"];

                if (savedTags != tagBox.Text)
                {
                    List <string> strTags = tagBox.Text.Split(' ').ToList();
                    List <long>   tags    = new List <long>();

                    foreach (string strTag in strTags)
                    {
                        try
                        {
                            tags.Add(productService.AddTag(strTag.ToLower()));
                        }
                        catch (DuplicateInstanceException)
                        {
                            tags.Add(productService.FindTagByName(strTag).tagId);
                        }
                    }

                    productService.UpdateComment(commentId, commentBody.Text, tags);
                }
                else
                {
                    productService.UpdateComment(commentId, commentBody.Text);
                }

                long productId = productService.FindCommentById(commentId).productId;

                Response.Redirect(
                    Response.ApplyAppPathModifier("~/Pages/Product/ProductComments.aspx?product=" + productId.ToString()));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                long productId = long.Parse(Request.Params.Get("product"));

                tagBox.Visible        = false;
                commentBody.Visible   = false;
                btnAddComment.Visible = false;

                lnkBack.NavigateUrl = "~/Pages/Product/ProductDetails.aspx?product=" + productId.ToString();

                if (!SessionManager.IsUserAuthenticated(Context))
                {
                    lblUnlogedUser.Visible = true;
                    tagBox.Visible         = false;
                    commentBody.Visible    = false;
                    btnAddComment.Visible  = false;
                    return;
                }
                /* Get the Service */
                IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IProductService productService = iocManager.Resolve <IProductService>();

                productService.FindCommentByProductAndUser(productId,
                                                           SessionManager.GetUserSession(Context).UserProfileId);

                lblCommented.Visible = true;
            }
            catch (ArgumentNullException)
            {
                lblNoProduct.Visible  = true;
                tagBox.Visible        = false;
                commentBody.Visible   = false;
                btnAddComment.Visible = false;
                lnkBack.NavigateUrl   = "~/Pages/Product/ProductSearch.aspx";
            }
            catch (InstanceNotFoundException)
            {
                tagBox.Visible        = true;
                commentBody.Visible   = true;
                btnAddComment.Visible = true;
            }
        }
 private void ChangeDefault()
 {
     if (paymentMethod == false)
     {
         IIoCManager  iocManager  = (IIoCManager)HttpContext.Current.Application["managerIoC"];
         ICardService cardService = (ICardService)iocManager.Resolve <ICardService>();
         CardDetails  card        = cardService.GetUserDefaultCard(SessionManager.GetUserSession(Context).UserProfileId);
         if (card != null)
         {
             cardId                 = card.CardId;
             cardNumber             = card.CardNumber;
             cardType               = card.CardType;
             expirateTime           = card.ExpirateTime.ToString();
             txtId.Text             = cardId.ToString();
             txtCardNumber.Text     = cardNumber.ToString();
             txtType.Text           = cardType;
             txtExpirationTime.Text = expirateTime;
         }
     }
 }
        protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                /* Get the Service */
                IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IProductService productService = iocManager.Resolve <IProductService>();

                Comment comment = productService.FindCommentById(long.Parse(e.Row.Cells[0].Text));

                // Find ListBox
                TextBox box = (TextBox)e.Row.FindControl("TextTags");

                box.Text = "";
                foreach (Tag tag in comment.Tags)
                {
                    box.Text += tag.tagName + "\n";
                }
            }
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

                HttpCookie           cookie      = Request.Cookies["loginName"];
                List <DTOGroupsUser> groupsUsers = recommendationGroupService.ShowUserGroups(cookie.Value);

                if (groupsUsers.Count == 0)
                {
                    lblNoGroups.Visible = true;
                    lblGroups.Visible   = false;
                    return;
                }
                lblGroups.Visible = false;

                #region //Forma normal

                //this.gvGroups.DataSource = groupsUsers;
                //this.DataBind();

                #endregion //Forma normal

                #region    //Forma opcional : Utilizando paquete Nuget: FastMember

                DataTable table = new DataTable();
                using (var reader = ObjectReader.Create(groupsUsers, "group_usersId", "gr_name"))
                {
                    table.Load(reader);
                }
                ViewState["groups"]      = table;
                this.gvGroups.DataSource = (DataTable)ViewState["groups"];;
                this.DataBind();

                this.gvGroups.Columns[0].Visible = false;

                #endregion //Forma opcional : Utilizando paquete Nuget: FastMember
            }
        }
Esempio n. 12
0
        protected void BtnCreateRecommendation_Click(object sender, EventArgs e)
        {
            this.lblError.Visible            = false;
            this.lblSuccess.Visible          = false;
            this.lblNoGroupsSelected.Visible = false;

            IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();
            List <long> groupsChecked = new List <long>();

            foreach (GridViewRow row in gvGroups.Rows)
            {
                long groupId = Convert.ToInt64(gvGroups.DataKeys[row.RowIndex].Value.ToString());

                var chk = row.FindControl("chkGroup") as CheckBox;
                if (chk != null && chk.Checked)
                {
                    groupsChecked.Add(groupId);
                }
            }

            if (groupsChecked.Count != 0)
            {
                try
                {
                    long       eventId = (long)ViewState["eventId"];
                    HttpCookie cookie  = Request.Cookies["loginName"];
                    recommendationGroupService.AddRecommendation(cookie.Value, eventId, groupsChecked, this.txtRecommend.Value);
                }
                catch (Exception)
                {
                    lblError.Visible = true;
                }
                this.lblSuccess.Visible = true;
            }
            else
            {
                this.lblNoGroupsSelected.Visible = true;
            }
        }
Esempio n. 13
0
        protected int GetFontSize(Object references)
        {
            /* Get the Service */
            IIoCManager   iocManager   = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IEventService eventService = iocManager.Resolve <IEventService>();

            if (totalReferences == 0)
            {
                totalReferences = eventService.GetTotalReferences();
            }
            int size      = Settings.Default.Labels_FontSize;
            int increment = Settings.Default.Labels_FontIncrement;

            for (int i = Settings.Default.Labels_NumFontIncrements; i > 1; i--)
            {
                if ((int)references > totalReferences / i)
                {
                    size += increment;
                }
            }
            return(size);
        }
        protected void btnToPay_Click(object sender, EventArgs e)
        {
            IIoCManager           iocManager   = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IOrderService         orderService = (IOrderService)iocManager.Resolve <IOrderService>();
            long                  usrId        = SessionManager.GetUserSession(Context).UserProfileId;
            List <ProductDetails> products     = SessionManager.shoppingCart;
            long                  cardId       = (long)Convert.ToInt32(txtId.Text);
            int postalAddress = Convert.ToInt32(txtPostalAddress.Text);

            try
            {
                orderService.GenerateOrder(usrId, cardId, postalAddress, products);
                CleanCache();
                SessionManager.shoppingCart.Clear();
                paymentMethod = false;
                string message = GetLocalResourceObject("message.Text").ToString();
                Response.Write("<script language=javascript>alert('" + message + "'); location.href='/Pages/MainPage.aspx';</script>");
            }
            catch (InsuficientNumberOfUnitsException w)
            {
                lblError.Visible = true;
                lblError.Text    = GetLocalResourceObject("lblError.Text").ToString() + " " + w.Message.ToString();
            }
        }
Esempio n. 15
0
        /// <summary>Handles the Click event of the btnEditComment control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void BtnEditComment_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string commentId  = Session["commentId"].ToString();
                string txtComment = this.txtComment.Value;

                IIoCManager        ioCManager        = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                ISportEventService sportEventService = ioCManager.Resolve <ISportEventService>();
                long commentIdfinal = Convert.ToInt64(commentId);
                try
                {
                    sportEventService.UpdateComment(commentIdfinal, txtComment);
                    this.lblSuccess.Visible     = true;
                    this.btnEditComment.Visible = false;
                }
                catch (Exception)
                {
                    this.lblError.Text   += txtComment;
                    this.lblError.Visible = true;
                    return;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int  startIndex, count;
            long productId;

            lnkPrevious.Visible   = false;
            lnkNext.Visible       = false;
            lblNoComments.Visible = false;
            btnDelete.Visible     = false;
            btnModify.Visible     = false;

            /* Get productId */
            try
            {
                productId = long.Parse(Request.Params.Get("product"));
                btnDelete.Attributes["name"] = productId.ToString();
            }
            catch (ArgumentNullException)
            {
                lblNoComments.Visible = true;
                lnkBack.NavigateUrl   = "~/Pages/Product/ProductSearch.aspx";
                return;
            }

            lnkBack.NavigateUrl = "~/Pages/Product/ProductDetails.aspx?product=" + productId.ToString();

            /* Get Start Index */
            try
            {
                startIndex = int.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            /* Get Count */
            try
            {
                count = int.Parse(Request.Params.Get("count"));
            }
            catch (ArgumentNullException)
            {
                count = Settings.Default.PracticaMaD_defaultCount;
            }

            /* Get the Service */
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = iocManager.Resolve <IProductService>();

            /* Get Products Info */
            CommentBlock commentBlock =
                productService.FindAllProductComments(productId, startIndex, count);

            if (commentBlock.Comments.Count == 0)
            {
                lblNoComments.Visible = true;
                return;
            }

            gvProducts.DataSource = commentBlock.Comments;
            gvProducts.DataBind();

            /* "Previous" link */
            if ((startIndex - count) >= 0)
            {
                string url =
                    "~/Pages/Product/ProductComments.aspx" + "?product=" + productId +
                    "&startIndex=" + (startIndex - count) + "&count=" + count;

                lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                lnkPrevious.Visible     = true;
            }

            /* "Next" link */
            if (commentBlock.ExistMoreComments)
            {
                string url =
                    "~/Pages/Product/ProductComments.aspx" + "?product=" + productId +
                    "&startIndex=" + (startIndex + count) + "&count=" + count;

                lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                lnkNext.Visible     = true;
            }

            Comment comment = null;

            if (SessionManager.IsUserAuthenticated(Context))
            {
                try
                {
                    comment = productService.FindCommentByProductAndUser(productId,
                                                                         SessionManager.GetUserSession(Context).UserProfileId);

                    cellOwnCommentId.Text          = comment.commentId.ToString();
                    cellOwnCommentProfileName.Text = comment.UserProfile.loginName;
                    cellOwnCommentBody.Text        = comment.comment1;
                    cellOwnCommentDate.Text        = comment.commentDate.ToString("d/M/yyyy");
                    cellOwnCommentTags.Text        = "";
                    foreach (Tag tag in comment.Tags)
                    {
                        cellOwnCommentTags.Text += tag.tagName + " <br/>";
                    }

                    ownComment.Visible = true;
                    btnDelete.Visible  = true;
                    btnModify.Visible  = true;
                }
                catch (InstanceNotFoundException)
                {
                    ownComment.Visible = false;
                }
            }
            else
            {
                ownComment.Visible = false;
            }
        }
Esempio n. 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IIoCManager container = (IIoCManager)HttpContext.Current.Application["managerIoC"];

            userService = container.Resolve <IUserService>();
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    startIndex, count;
            string selectedValue = "-1";

            lnkPrevious.Visible    = false;
            lnkNext.Visible        = false;
            lblNoProducts.Visible  = false;
            lblAmountError.Visible = false;

            /* Get the Service */
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = iocManager.Resolve <IProductService>();

            /* Get Start Index */
            try
            {
                startIndex = int.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            /* Get Count */
            try
            {
                count = int.Parse(Request.Params.Get("count"));
            }
            catch (ArgumentNullException)
            {
                count = Settings.Default.PracticaMaD_defaultCount;
            }

            /* Get keyword */
            string keyword = Request.Params.Get("keyword");

            if (keyword != null)
            {
                txtSearch.Text = keyword;

                /* Get category id */
                try
                {
                    long catId = long.Parse(Request.Params.Get("category"));

                    selectedValue = Request.Params.Get("category");

                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProductsByKeyword(keyword, catId, startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword + "&category=" + catId +
                                "&startIndex=" + (startIndex - count) + "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword + "&category=" + catId +
                                "&startIndex=" + (startIndex + count) + "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
                catch (ArgumentNullException)
                {
                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProductsByKeyword(keyword, startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword +
                                "&startIndex=" + (startIndex - count) + "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?keyword=" + keyword +
                                "&startIndex=" + (startIndex + count) + "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
            }
            /* If there is no keyword, search all products */
            else
            {
                try
                {
                    long tagId = long.Parse(Request.Params.Get("tagId"));

                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProductsByTag(tagId, startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?tagId=" + tagId + "startIndex=" + (startIndex - count) +
                                "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?tagId=" + tagId + "startIndex=" + (startIndex + count) +
                                "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
                catch (ArgumentNullException)
                {
                    /* Get Products Info */
                    ProductBlock productBlock = productService.FindAllProducts(startIndex, count);

                    if (productBlock.Products.Count == 0)
                    {
                        lblNoProducts.Visible = true;
                    }
                    else
                    {
                        gvProducts.DataSource = productBlock.Products;
                        gvProducts.DataBind();

                        /* "Previous" link */
                        if ((startIndex - count) >= 0)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?startIndex=" + (startIndex - count) +
                                "&count=" + count;

                            lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkPrevious.Visible     = true;
                        }

                        /* "Next" link */
                        if (productBlock.ExistMoreProducts)
                        {
                            string url =
                                "~/Pages/Product/ProductSearch.aspx" + "?startIndex=" + (startIndex + count) +
                                "&count=" + count;

                            lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                            lnkNext.Visible     = true;
                        }
                    }
                }
            }

            if (!IsPostBack)
            {
                List <Category> categories = productService.FindAllCategories();

                // Create a table to store data for the DropDownList control.
                DataTable dt = new DataTable();

                // Define the columns of the table.
                dt.Columns.Add(new DataColumn("CategoryNameField", typeof(string)));
                dt.Columns.Add(new DataColumn("CategoryIdField", typeof(long)));

                // Populate the table.
                dt.Rows.Add(CreateRow("-", -1, dt));

                foreach (Category category in categories)
                {
                    dt.Rows.Add(CreateRow(category.categoryName, category.categoryId, dt));
                }

                // Create a DataView from the DataTable to act as the data source
                // for the DropDownList control.
                DataView dv = new DataView(dt);

                CategoryDropDownList.DataSource     = dv;
                CategoryDropDownList.DataTextField  = "CategoryNameField";
                CategoryDropDownList.DataValueField = "CategoryIdField";

                // Bind the data to the control.
                CategoryDropDownList.DataBind();

                // Set the default selected item.
                CategoryDropDownList.SelectedValue = selectedValue;
            }
        }
Esempio n. 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /* Get the Service */
            IIoCManager   iocManager   = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IEventService eventService = iocManager.Resolve <IEventService>();

            if (!IsPostBack)
            {
                this.GvLabels.DataSource = eventService.GetLabelsDtos();
                this.GvLabels.DataBind();
            }

            if (!SessionManager.IsUserAuthenticated(Context))
            {
                if (lblDash2 != null)
                {
                    lblDash2.Visible = false;
                }
                if (lnkUpdate != null)
                {
                    lnkUpdate.Visible = false;
                }
                if (lblDash3 != null)
                {
                    lblDash3.Visible = false;
                }
                if (lnkLogout != null)
                {
                    lnkLogout.Visible = false;
                }
                if (lblDash5 != null)
                {
                    lblDash5.Visible = false;
                }
                if (lnkNewGroup != null)
                {
                    lnkNewGroup.Visible = false;
                }
                if (lblDash6 != null)
                {
                    lblDash6.Visible = false;
                }
                if (lnkMyGroups != null)
                {
                    lnkMyGroups.Visible = false;
                }
                if (lblDash7 != null)
                {
                    lblDash7.Visible = false;
                }
                if (lnkAddLabel != null)
                {
                    lnkAddLabel.Visible = false;
                }
            }
            else
            {
                if (lblWelcome != null)
                {
                    lblWelcome.Text =
                        GetLocalResourceObject("lblWelcome.Hello.Text").ToString()
                        + " " + SessionManager.GetUserSession(Context).FirstName;
                }
                if (lblDash1 != null)
                {
                    lblDash1.Visible = false;
                }
                if (lnkAuthenticate != null)
                {
                    lnkAuthenticate.Visible = false;
                }
            }
        }
Esempio n. 20
0
        protected void callService()
        {
            IIoCManager container = (IIoCManager)HttpContext.Current.Application["managerIoC"];

            eventService = container.Resolve <IEventService>();
        }
Esempio n. 21
0
 protected void btnAddCard_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         if (lblCardNumberFormat.Visible == true)
         {
             lblCardNumberFormat.Visible = false;
         }
         if (lblCardTypeError.Visible == true)
         {
             lblCardTypeError.Visible = false;
         }
         if (lblCardNumberError.Visible == true)
         {
             lblCardNumberError.Visible = false;
         }
         if (lblCVError.Visible == true)
         {
             lblCVError.Visible = true;
         }
         try
         {
             if (txtCardNumber.Text.Count() == 16)
             {
                 IIoCManager  iocManager  = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                 ICardService cardService = (ICardService)iocManager.Resolve <ICardService>();
                 string       cardNumber  = txtCardNumber.Text.ToString();
                 string       cardType;
                 if (chBDebit.Checked == true)
                 {
                     cardType = "Debit";
                 }
                 else if (chBCredit.Checked)
                 {
                     cardType = "Credit";
                 }
                 else
                 {
                     throw new Exception("cardType");
                 }
                 // txtType.Text.ToString();
                 Int16 cv         = 0;
                 bool  canConvert = Int16.TryParse(txtCV.Text, out cv);
                 if (!canConvert || txtCV.Text.Count() != 3)
                 {
                     throw new Exception("cv");
                 }
                 Int32       dd1            = Convert.ToInt32(dropMonth.SelectedItem.Text);
                 Int32       dd2            = Convert.ToInt32(dropYear.SelectedItem.Text);
                 DateTime    expirationTime = new DateTime(dd2, dd1, 1);
                 CardDetails newCard        = new CardDetails(cardNumber, cv, expirationTime, cardType);
                 cardService.AddCard(SessionManager.GetUserSession(Context).UserProfileId, newCard);
                 string message = GetLocalResourceObject("messageCard.Text").ToString();
                 //Response.Redirect(Response.ApplyAppPathModifier("~/Pages/Card/SeeMyCards.aspx"));
                 Response.Write("<script language=javascript>alert('" + message + "'); location.href='/Pages/Card/SeeMyCards.aspx';</script>");
             }
             else
             {
                 lblCardNumberFormat.Visible = true;
             }
         }
         catch (IncorrectCardNumberFormatException)
         {
             lblCardNumberFormat.Visible = true;
         }
         catch (DuplicateInstanceException)
         {
             lblCardNumberError.Visible = true;
         }
         catch (Exception w)
         {
             if (w.Message.Equals("cv"))
             {
                 lblCVError.Visible = true;
             }
             else
             {
                 lblCardTypeError.Visible = true;
             }
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            lblProductError.Visible  = false;
            TableProductInfo.Visible = false;
            hlComments.Visible       = true;
            hlAddComment.Visible     = false;

            long productId;

            /* Get productId */
            try
            {
                productId = long.Parse(Request.Params.Get("product"));
            }
            catch (ArgumentNullException)
            {
                lblProductError.Visible = true;
                return;
            }

            TableProductInfo.Visible = true;

            /* Get the Service */
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = iocManager.Resolve <IProductService>();

            /* Get Products Info */
            Model.Product product = productService.FindProduct(productId);

            cellProductID.Text       = product.productId.ToString();
            cellProductName.Text     = product.productName;
            cellCategoryName.Text    = product.Category.categoryName;
            cellProductDate.Text     = product.productDate.ToString("d/M/yyyy");
            cellProductPrice.Text    = product.productPrice.ToString("C", CultureInfo.CurrentCulture);
            cellProductQuantity.Text = product.productQuantity.ToString();

            hlComments.NavigateUrl =
                "~/Pages/Product/ProductComments.aspx" +
                "?product=" + product.productId;



            if (SessionManager.IsAdminAuthenticated(Context))
            {
                lnkUpdate.NavigateUrl += product.productId;
                lnkUpdate.Visible      = true;
            }

            if (SessionManager.IsUserAuthenticated(Context))
            {
                try
                {
                    productService.FindCommentByProductAndUser(productId,
                                                               SessionManager.GetUserSession(Context).UserProfileId);

                    lblDash1.Visible = false;
                }
                catch (InstanceNotFoundException)
                {
                    hlAddComment.Visible = true;
                }
            }
            else
            {
                hlAddComment.Visible = true;
            }

            hlAddComment.NavigateUrl = "~/Pages/Product/AddComment.aspx" +
                                       "?product=" + productId;

            if (product.Comments.Count == 0)
            {
                hlComments.Visible = false;
                lblDash1.Visible   = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int startIndex, count;

            string category, keywords;

            count = Settings.Default.PracticaMaD_defaultCount;
            //Obtain keywords

            try
            {
                keywords = Convert.ToString(Request.Params.Get("keywords"));
            }
            catch (ArgumentNullException)
            {
                keywords = "";
            }

            try
            {
                //Obtain category
                category = Convert.ToString(Request.Params.Get("category"));
            }
            catch (ArgumentNullException)
            {
                category = null;
            }

            try
            {
                startIndex = Int32.Parse(Request.Params.Get("startIndex"));
            }
            catch (ArgumentNullException)
            {
                startIndex = 0;
            }

            IIoCManager        ioCManager        = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            ISportEventService sportEventService =
                ioCManager.Resolve <ISportEventService>();
            SportEventBlock sportEventBlock;

            if (category != null)
            {
                sportEventBlock = sportEventService.FindEvents(keywords, startIndex, count, category);
            }
            else
            {
                sportEventBlock = sportEventService.FindEvents(keywords, startIndex, count);
            }

            if (sportEventBlock.result.Count == 0)
            {
                lblResultsEvents.Visible        = false;
                lblNotCoincidenceEvents.Visible = true;
                return;
            }

            List <DTOSportEvent> sportEvents = sportEventBlock.result;

            this.gvEvents.DataSource = sportEvents;

            this.gvEvents.DataBind();
            gvEvents.Columns[0].Visible = false;

            // Previus link
            if ((startIndex - count) >= 0)
            {
                string url =
                    "/Pages/SportEvents/ResultSearchEvents.aspx" +
                    "?category=" + category + "&keywords=" + keywords +
                    "&startIndex=" + (startIndex - count);
                this.lnkPrevious.NavigateUrl = Response.ApplyAppPathModifier(url);
                this.lnkPrevious.Visible     = true;
            }

            if (sportEventBlock.existMoreSportEvents)
            {
                string url =
                    "/Pages/SportEvents/ResultSearchEvents.aspx" +
                    "?category=" + category + "&keywords=" + keywords +
                    "&startIndex=" + (startIndex + count);

                this.lnkNext.NavigateUrl = Response.ApplyAppPathModifier(url);
                this.lnkNext.Visible     = true;
            }
        }