Example #1
0
        static SessionManager()
        {
            IIoCManager iocManager =
                (IIoCManager)HttpContext.Current.Application["managerIoC"];

            userService = iocManager.Resolve <IUserService>();
        }
        /// <summary>
        /// Handles the Click event of the btnUserExists 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 btnUserExists_Click(object sender, EventArgs e)
        {
            // 1) Obtener contexto de Inyección de Dependencias

            IIoCManager iocManager = (IIoCManager)Application["managerIoC"];

            // 2) Obtención del Servicio

            IUserService userService = iocManager.Resolve <IUserService>();

            // 3) Llamada al caso de uso (lectura de parámetros y actualización vista)

            this.lblUserExists.Visible    = false;
            this.lblUserNotExists.Visible = false;

            String loginName =
                txtUserName.Text;

            bool userExists = userService.UserExists(loginName);

            if (userExists)
            {
                this.lblUserExists.Visible = true;
            }
            else
            {
                this.lblUserNotExists.Visible = true;
            }
        }
Example #3
0
        protected void CreateLabelClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                /* Create an Account. */
                String labelName = txtLabel.Text;

                Model.Label label = new Model.Label();
                label.name = labelName;

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

                try
                {
                    Model.Label labelCreated = eventService.Create(label);

                    Context.Items.Add("createdGroup", labelCreated);

                    LogManager.RecordMessage("Label " + label.name + " created.", MessageType.Info);

                    Server.Transfer(Response.ApplyAppPathModifier("~/Pages/EventPages/Home.aspx"));
                }
                catch (DuplicateInstanceException)
                {
                    Server.Transfer(Response.ApplyAppPathModifier("~/Pages/Errors/InternalError.aspx"));
                }
            }
        }
Example #4
0
        private void callService()
        {
            IIoCManager container = (IIoCManager)HttpContext.Current.Application["managerIoC"];

            eventService = container.Resolve <IEventService>();
            ICollection <EventDto> eventDto = eventService.FindAllEvents();
        }
Example #5
0
        /// <summary>Handles the RowDeleting event of the gvGroups control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewDeleteEventArgs" /> instance containing the event data.</param>
        protected void GvGroups_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lblErrorOwner.Visible = false;
            lblSuccess.Visible    = false;
            //TableCell cell = gvGroups.Rows[e.RowIndex].Cells[2];
            long groupId = Convert.ToInt64(gvGroups.DataKeys[e.RowIndex].Value.ToString());

            IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();
            HttpCookie cookie = Request.Cookies["loginName"];

            try {
                recommendationGroupService.AbandonGroup(cookie.Value, groupId);
                DataTable dt = (DataTable)ViewState["groups"];
                dt.Rows[e.RowIndex].Delete();
                dt.AcceptChanges();
                ViewState["groups"] = dt;
                lblSuccess.Visible  = true;
                gvGroups.DataSource = dt;
                gvGroups.DataBind();
            }
            catch (OwnerGroupAbandonException)
            {
                lblErrorOwner.Visible = true;
                e.Cancel = true;
                return;
            }
        }
        /// <summary>Handles the RowDeleting event of the GvFavorites control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewDeleteEventArgs" /> instance containing the event data.</param>
        protected void GvFavorites_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            this.lblError.Visible   = false;
            this.lblSuccess.Visible = false;

            long eventId = Convert.ToInt64(gvFavorites.DataKeys[e.RowIndex].Value.ToString());

            IIoCManager        ioCManager        = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            ISportEventService sportEventService = ioCManager.Resolve <ISportEventService>();
            HttpCookie         cookie            = Request.Cookies["loginName"];

            try
            {
                sportEventService.DeleteFromFavorites(cookie.Value, eventId);
            }
            catch (Exception)
            {
                this.lblError.Visible = true;
                e.Cancel = true;
                return;
            }

            DataTable dt = (DataTable)ViewState["favorites"];

            dt.Rows[e.RowIndex].Delete();
            if (dt.Rows.Count == 0)
            {
                this.lblNoFavorites.Visible = true;
                this.lblFavorites.Visible   = false;
            }
            ViewState["favorites"] = dt;
            lblSuccess.Visible     = true;
            gvFavorites.DataSource = dt;
            gvFavorites.DataBind();
        }
        /// <summary>Handles the Click event of the btnAddFavorite 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 BtnAddFavorite_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string eventIdString = Session["eventId"].ToString();
                if (eventIdString == null)
                {
                    this.lblError.Visible = true;
                    return;
                }

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

                long       eventId      = Convert.ToInt64(eventIdString);
                string     favoriteName = this.favoriteName.Text;
                string     favoriteDesc = this.txtFavorite.Value;
                HttpCookie cookie       = Request.Cookies["loginName"];
                try
                {
                    sportEventService.AddToFavorites(cookie.Value, eventId, favoriteName, favoriteDesc);
                    this.btnAddFavorite.Visible = false;
                    this.lblSuccess.Visible     = true;
                }
                catch (Exception)
                {
                    this.lblError.Visible = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

            HttpCookie cookie    = Request.Cookies["loginName"];
            DataTable  dataTable = new DataTable();

            HashSet <DTORecommendation> recommendations = recommendationGroupService.ShowUserRecommendations(cookie.Value);

            if (recommendations.Count == 0)
            {
                this.lblNorecommendations.Visible = true;
                this.lblRecommendations.Visible   = false;
                return;
            }

            using (var reader = ObjectReader.Create(recommendations, "recommendationId", "eventId", "login_user", "eventName", "recommendation_text"))
            {
                dataTable.Load(reader);
            }

            this.gvRecommendations.DataSource = dataTable;
            this.DataBind();
            gvRecommendations.Columns[0].Visible = false;
            gvRecommendations.Columns[1].Visible = false;
        }
 public DapperDbContextProvider(IIoCManager ioCManager)
 {
     if (ioCManager == null)
     {
         throw new ArgumentNullException(nameof(_ioCManager));
     }
 }
Example #10
0
        /// <summary>Handles the Click event of the BtnCreateComment 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 BtnCreateComment_Click(object sender, EventArgs e)
        {
            this.lblSuccess.Visible = false;
            this.lblError.Visible   = false;
            if (Page.IsValid)
            {
                long eventId = (long)ViewState["eventId"];

                string comment = txtComment.Value;

                IIoCManager        ioCManager        = (IIoCManager)Application["managerIoC"];
                ISportEventService sportEventService = ioCManager.Resolve <ISportEventService>();
                HttpCookie         cookie            = Request.Cookies["loginName"];
                try
                {
                    //long eventId = Convert.ToInt64(Request.Params.Get("sportEventId"));
                    sportEventService.AddComment(cookie.Value, eventId, comment);
                    this.btnCreateComment.Visible = false;
                    this.lblSuccess.Visible       = true;
                }
                catch (Exception)
                {
                    this.lblError.Visible = true;
                }
            }
        }
Example #11
0
        /// <summary>Creates the group click.</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void CreateGroupClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    string      groupName        = this.txtNameGroup.Text;
                    string      groupDescription = txtDescriptionGroup.Value;
                    IIoCManager ioCManager       = (IIoCManager)Application["managerIoC"];

                    IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();
                    HttpCookie cookie = Request.Cookies["loginName"];
                    try
                    {
                        recommendationGroupService.CreateGroup(groupName, groupDescription, cookie.Value);
                        //Response.Redirect(Response.ApplyAppPathModifier("~/Pages/MainPage.aspx"));
                        this.lblGroupCreated.Visible = true;
                        this.btnCreateGroup.Visible  = false;
                    }
                    catch (GroupAlreadyExistsException)
                    {
                        this.lblGroupError.Visible = true;
                    }
                }
                catch (DuplicateInstanceException)
                {
                    this.lblGroupError.Visible = true;
                }
            }
        }
Example #12
0
        protected void LnkSubscribeUser_Click(object sender, EventArgs e)
        {
            lblError.Visible      = false;
            lblSubscribed.Visible = false;
            LinkButton  btn     = sender as LinkButton;
            GridViewRow row     = btn.NamingContainer as GridViewRow;
            long        groupId = Convert.ToInt64(gvAllGroups.DataKeys[row.RowIndex].Value.ToString());

            HttpCookie  cookie     = Request.Cookies["loginName"];
            IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();

            try
            {
                recommendationGroupService.AddUserToGroup(cookie.Value, groupId);
                var lnk = (LinkButton)row.FindControl("lnkSubscribeUser");

                if (lnk != null)
                {
                    lnk.Visible = false;
                }

                var lbl = (Label)row.FindControl("lblSubscribed");
                if (lbl != null)
                {
                    lbl.Visible = true;
                }
                this.lblSubscribed.Visible = true;
            }
            catch (Exception)
            {
                lblError.Text    = "Something go wrong";
                lblError.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                HttpCookie cookie = Request.Cookies["loginName"];

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

                List <DTOFavorite> dtoFavorites = sportEventService.ListFavorites(cookie.Value);
                DataTable          dataTable    = new DataTable();

                if (dtoFavorites.Count == 0)
                {
                    this.lblNoFavorites.Visible = true;
                    this.lblFavorites.Visible   = false;
                    return;
                }

                using (var reader = ObjectReader.Create(dtoFavorites, "eventId", "fv_name", "fv_date", "comment"))
                {
                    dataTable.Load(reader);
                }

                ViewState["favorites"] = dataTable;

                this.gvFavorites.DataSource = dataTable;
                this.DataBind();
                this.gvFavorites.Columns[0].Visible = false;
            }
        }
Example #14
0
        protected void callService()
        {
            /* Get the Service */
            IIoCManager iocManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];

            eventService = iocManager.Resolve <IEventService>();
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Page.IsPostBack)
            //{
            IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();
            List <DTOGroups>            groups = recommendationGroupService.ShowAllGroups();

            if (groups.Count == 0)
            {
                this.lblNoGroups.Visible = true;
                return;
            }
            else
            {
                this.lblGroups.Visible = true;
            }

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

            DataTable table = new DataTable();
            using (var reader = ObjectReader.Create(groups, "group_usersId", "gr_name", "gr_description", "gr_amount_users", "gr_amount_recommendation"))
            {
                table.Load(reader);
            }

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

            this.gvAllGroups.DataSource = table;
            this.DataBind();

            this.gvAllGroups.Columns[0].Visible = false;
        }
Example #16
0
        protected void callService()
        {
            IIoCManager container = (IIoCManager)HttpContext.Current.Application["managerIoC"];

            userService  = container.Resolve <IUserService>();
            eventService = container.Resolve <IEventService>();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    long commentId = long.Parse(Request.Params.Get("comment"));

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

                    Comment comment = null;

                    try
                    {
                        comment = productService.FindCommentById(commentId);
                    }
                    catch (InstanceNotFoundException)
                    {
                        lblNoComment.Visible   = true;
                        tagBox.Visible         = false;
                        commentBody.Visible    = false;
                        btnEditComment.Visible = false;

                        return;
                    }

                    if (!SessionManager.IsUserAuthenticated(Context) ||
                        SessionManager.GetUserSession(Context).UserProfileId != comment.userId)
                    {
                        lblUnlogedUser.Visible = true;
                        tagBox.Visible         = false;
                        commentBody.Visible    = false;
                        btnEditComment.Visible = false;

                        return;
                    }

                    commentBody.Text = comment.comment1;
                    string tagStr = "";

                    foreach (Tag tag in comment.Tags)
                    {
                        tagStr = tagStr + tag.tagName + " ";
                    }

                    tagBox.Text       = tagStr.Trim(' ');
                    ViewState["tags"] = tagStr.Trim(' ');
                }
                catch (ArgumentNullException)
                {
                    lblNoComment.Visible   = true;
                    tagBox.Visible         = false;
                    commentBody.Visible    = false;
                    btnEditComment.Visible = false;
                }
            }
        }
Example #18
0
 public CommandBusDependencyRegister(IIoCManager ioCManager)
 {
     if (_ioCManager != null)
     {
         _ioCManagerThunk = () => _ioCManager;
     }
     _commandBusTypeProviderThunk = () => new DefaultCommandBusTypeProvider();
 }
Example #19
0
 public EfCoreDbContextProvider(IIoCManager ioCManager)
 {
     if (ioCManager == null)
     {
         throw new ArgumentNullException(nameof(ioCManager));
     }
     _ioCManager = ioCManager;
 }
        protected void PbpDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            /* Get the Service */
            IIoCManager     iocManager     = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            IProductService productService = (IProductService)iocManager.Resolve <IProductService>();

            e.ObjectInstance = (IProductService)productService;
        }
Example #21
0
        public void Register(IIoCManager ioCManager, Assembly assembly)
        {
            var queryInterfaceImpls = FindQueryEntry(assembly);

            queryInterfaceImpls.ForEach(p => ioCManager.AddPerDependency(p.Interface, p.Impl));
            var repositoryInterfaceImpls = FindRepository(assembly);

            repositoryInterfaceImpls.ForEach(p => ioCManager.AddPerDependency(p.Interface, p.Impl));
        }
 public EventBusDependencyRegister(IIoCManager ioCManager)
 {
     if (ioCManager == null)
     {
         throw new ArgumentNullException(nameof(ioCManager));
     }
     _ioCManagerThunk           = () => ioCManager;
     _eventBusTypeProviderThunk = () => new DefaultEventBusTypeProvider();
 }
Example #23
0
        public DapperUnitOfWorkDbContextProvider(IUnitOfWorkManager uowManager, IIoCManager ioCManager, ILoggerFactory logger)
        {
            if (ioCManager == null)
            {
                throw new ArgumentNullException(nameof(_ioCManager));
            }

            UowManager = uowManager;
            logger.CreateLogger <DapperUnitOfWorkDbContextProvider>().LogDebug("CONSTRUCT> EfUnitOfWorkDbContextProvider");
        }
        protected void gvAllCards_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            GridViewRow row        = gvAllCards.Rows[e.NewSelectedIndex];
            long        cardId     = (long)Convert.ToInt32(row.Cells[3].Text);
            IIoCManager iocManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            ICardDao    cardDao    = (ICardDao)iocManager.Resolve <ICardDao>();

            cardDao.Remove(cardId);
            Response.Redirect(Request.RawUrl.ToString());
        }
        static SessionManager()
        {
            IIoCManager iocManager =
                (IIoCManager)HttpContext.Current.Application["managerIoC"];

            shoppingCart    = new List <ProductDetails>();
            UserService     = iocManager.Resolve <IUserService>();
            ProductService  = iocManager.Resolve <IProductService>();
            CategoryService = iocManager.Resolve <ICategoryService>();
            TagService      = iocManager.Resolve <ITagService>();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         lblAutenticated.Visible = false;
         IIoCManager iocManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
         ITagService tagService = (ITagService)iocManager.Resolve <ITagService>();
         long        tagId      = Convert.ToInt32(Request.Params.Get("tagId"));
         lclTagName.Text = tagService.FinTagById(tagId).name;
         LoadGrid();
     }
 }
Example #27
0
        /// <summary>Handles the RowDataBound event of the gvAllGroups control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewRowEventArgs" /> instance containing the event data.</param>
        protected void GvAllGroups_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (SessionManager.IsUserAuthenticated(Context) &&
                e.Row.RowType == DataControlRowType.DataRow)
            {
                HttpCookie  cookie     = Request.Cookies["loginName"];
                IIoCManager ioCManager = (IIoCManager)HttpContext.Current.Application["managerIoC"];
                IRecommendationGroupService recommendationGroupService = ioCManager.Resolve <IRecommendationGroupService>();
                //Quiza despues en vez de DTOs, añado al viewState todos los ids.
                List <DTOGroupsUser> groupsFromUser = recommendationGroupService.ShowUserGroups(cookie.Value);

                long idRow       = Convert.ToInt64(gvAllGroups.DataKeys[e.Row.RowIndex].Values[0].ToString());
                bool coincidence = false;
                //this.lblError.Text += "RowDataBound id= " + idRow;
                //this.lblError.Visible = true;
                foreach (DTOGroupsUser group in groupsFromUser)
                {
                    if (idRow == group.group_usersId)
                    {
                        coincidence = true;
                        break;
                    }
                }

                if (coincidence)
                {
                    var lbl = (Label)e.Row.FindControl("lblSubscribed");
                    var lnk = (HyperLink)e.Row.FindControl("lnkSubscribeAuth");
                    if (lbl != null)
                    {
                        //lbl.Text = "Already subscribed";
                        lbl.Visible = true;
                    }
                    if (lnk != null)
                    {
                        lnk.Visible = false;
                    }
                }
                else
                {
                    var lnk = (HyperLink)e.Row.FindControl("lnkSubscribeAuth");
                    if (lnk != null)
                    {
                        lnk.Visible = false;
                    }
                    var lnkAuthUser = (LinkButton)e.Row.FindControl("lnkSubscribeUser");
                    if (lnkAuthUser != null)
                    {
                        lnkAuthUser.Visible = true;
                    }
                }
            }
        }
        protected void changeDefaultCard_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox     checkBox    = sender as CheckBox;
            GridViewRow  row         = checkBox.NamingContainer as GridViewRow;
            long         cardId      = (long)Convert.ToInt32(row.Cells[3].Text.ToString());
            long         usrId       = SessionManager.GetUserSession(Context).UserProfileId;
            IIoCManager  iocManager  = (IIoCManager)HttpContext.Current.Application["managerIoC"];
            ICardService cardService = (ICardService)iocManager.Resolve <ICardService>();

            cardService.ChangeDefaultCard(usrId, cardId);
            LoadGrid();
        }
Example #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IIoCManager container = (IIoCManager)HttpContext.Current.Application["managerIoC"];

            userService = container.Resolve <IUserService>();
            initFromsValues();

            if (!IsPostBack)
            {
                initGridView();
            }
        }
Example #30
0
 public EventHandlerDependencyRegister(IIoCManager ioCManager, IDependencyMapProvider commandHandlerTypeProvider, params Assembly[] assemblies)
 {
     if (_ioCManager != null)
     {
         _ioCManagerThunk = () => ioCManager;
     }
     if (commandHandlerTypeProvider != null)
     {
         _eventHandlerTypeProviderThunk = () => commandHandlerTypeProvider;
     }
     _assembliesThunk = () => assemblies;
 }
Example #31
0
		public void Configure(IIoCManager manager)
		{

			//设置测试环境IoC设置 返回一个新的IoC容器
		
			manager.ConfigureDefaultContianer(
				() =>
				{
					//新的IoC容器
					var c = new UnityIoCContainer(new IoCContext(manager,new ExpandoObject()));

					//注册一个自定义的connection string 
					c.GetContainerCore<IUnityContainer>()
						.RegisterType<MappedDbContext<object>>(//要替换其中参数所以调用了Unity底层
						 new InjectionConstructor(new InjectionParameter(typeof(string), _connectionString)));
				
					//对于这个实现,设定一个扫描程序集 运行其中所有的模型设置:
					c.RegisterInstance<System.Reflection.Assembly>(MappedDbContext<object>.RegisterModelConfiguresName, typeof(GroupConfiguration).Assembly);


					//默认DbContext实现注册
					c.RegisterType<DbContext, MappedDbContext<object>>();

					//默认UOW实现注册
					c.RegisterType<IUnitOfWork, EFUnitOfWork>();

			

					//注册业务组件实现
					c.RegisterType<IUserService, UserService>();
					c.RegisterType<IGroupService, GroupService>();
                    //注册Logger
                    c.RegisterType<IStandardLogger, StandardLogger>();
                    c.RegisterInstance<IChannel<StandardLevels>>("Debug",new DEAD.Logging.Log4net.Log4netStandardChannel("Debug",StandardLevels.Debug, log4net.LogManager.GetLogger("Debug")));


                    return c;
				});
		}
Example #32
0
		public void Configure(IIoCManager manager)
		{
			throw new NotImplementedException();
		}
Example #33
0
		public IoCContext(IIoCManager manager,object contextBag)
		{
			Manager = manager;
			ContextBag = contextBag;
		}