Example #1
0
        private Icon UpdateDatabase(Icon icon, IConnection connection)
        {
            if (icon.IsNew)
            {
                icon.DateChanged = DateTime.Now;
                icon.DateCreated = DateTime.Now;
                connection.IconTable.Add(icon);
                connection.Log("Portal", string.Format("Icon Added: {0}", icon.Name));
                connection.SaveChanges();
            }

            Icon recordedIcon = connection.IconByName(icon.Name);

            if (recordedIcon == null)
            {
                throw new PortalException(IconResult.FAIL_NOT_FOUND_AFTER_ADDED,
                                          string.Format("Icon '{0}' not found after added", icon.Name));
            }
            if (icon.IsNew == false)
            {
                recordedIcon.DateChanged = DateTime.Now;
                recordedIcon.Name        = icon.Name;
                recordedIcon.Link        = icon.Link;
                recordedIcon.Image       = icon.Image;
                connection.Log("Portal", string.Format("Icon Updated: {0}", icon.Name));
            }

            IconHistory history = recordedIcon.ToHistory();

            connection.IconHistoryTable.Add(history);
            connection.SaveChanges();

            return(recordedIcon);
        }
Example #2
0
        protected override void Before()
        {
            FakeConnectionFactory cf      = new FakeConnectionFactory();
            IconUploadRequest     request = new IconUploadRequest(cf,
                                                                  WebsiteState, IconValidatorService, new FakeEmptyFileReceiver());

            cf.IconInternal.Init(new Icon()
            {
                Id    = EXISTING_ID,
                Name  = EXISTING_NAME,
                Image = EXISTING_IMAGE,
                Link  = EXISTING_LINK
            });

            IconPost post = new IconPost()
            {
                Id   = EXISTING_ID,
                Name = EXISTING_NAME,
                Link = NEW_LINK
            };

            request.Process(post);

            newIcon = cf.IconInternal.Records.Single();
            history = cf.IconHistoryInternal.Records.Single();
        }
        protected override void Before()
        {
            FakeConnectionFactory cf = new FakeConnectionFactory();

            fileReceiver = new FakeFileReceiver(1, "Test File");
            IconUploadRequest request = new IconUploadRequest(cf,
                                                              WebsiteState, IconValidatorService, fileReceiver);

            IconPost post = new IconPost()
            {
                Id   = -1,
                Name = "test icon",
                Link = LINK
            };

            request.Process(post);

            newIcon = cf.IconInternal.Records.Single();
            history = cf.IconHistoryInternal.Records.Single();
        }