public void ProcessRequest(HttpContext context)
        {
            Uow = new JetNettApiUow(new RepositoryProvider(new RepositoryFactories()));
            context.Response.ContentType = "text/html";

            var stacks = context.Request["stacks"];
            var title = context.Request["title"];
            var sWidgetID = context.Request["widgetID"];
            _buttonClass = context.Request["buttonColor"];

            var widgetID = 1;

            int.TryParse(sWidgetID, out widgetID);

            if (widgetID == 0)
                widgetID = 1;

            if (stacks == null)
                return;
            var iStacks = stacks.Split(new[] { ',' });

            var stacksList = new List<JetNettApi.Models.Stack>();
            foreach (var s in iStacks)
            {
                var stackID = 0;
                int.TryParse(s, out stackID);
                if (stackID > 0)
                {
                    stacksList.Add(Uow.Stacks.GetById(stackID));
                }
            }

            const string templateFile = "buttonStackSelectorTemplate.html";
            var template = "";
            using (var fs = new FileStream(HttpContext.Current.Server.MapPath(templateFile), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (var reader = new StreamReader(fs))
                {
                    template = reader.ReadToEnd();
                }
            }

            var leftHtml = ""; var rightHtml = "";

            GetStacksHtml(stacksList, out leftHtml, out rightHtml);

            template = template.Replace("[%LEFT-LINKS%]", leftHtml);
            template = template.Replace("[%RIGHT-LINKS%]", rightHtml);
            template = template.Replace("[%TITLE%]", title);
            template = template.Replace("[%WIDGET-ID%]", widgetID + "");

            context.Response.Write(template);
        }
示例#2
0
        public void Db_context_save_changes_is_called_on_commit()
        {
            var mockContext = new Mock<JetNettApiDbContext>();

            var repoFactories = new RepositoryFactories();

            var repoProvider = new RepositoryProvider(null);

            var uow = new JetNettApiUow(repoProvider, mockContext.Object);

            uow.Commit();

            mockContext.Verify(x => x.SaveChanges());
        }