public virtual Homepage Update(Homepage homepage)
        {
            if (!homepage.IsDirty || homepage.IsNull)
            {
                // Nothing to do - no point hammering the database unnecessarily
                return(homepage);
            }

            IDbCommand command = CreateCommand();

            if (homepage.IsNew)
            {
                // Adding
                command.CommandText = "INSERT INTO [Homepage] ([BrandId], [IntroText], [Url1], [Url2], [Url3], [Url4], [BumperPageHtml], [BumperPageSkip], [CustomHtml], [HomepageTypeId], [IsPublished], [LastModifiedByUserId], [LastModifiedDate]) VALUES (@brandId, @introText, @url1, @url2, @url3, @url4, @bumperPageHtml, @bumperPageSkip, @customHtml, @homepageTypeId, @isPublished, @lastModifiedByUserId, @lastModifiedDate) ; SELECT @@identity AS NewId;";
            }
            else
            {
                // Updating
                command.CommandText = "UPDATE [Homepage] SET [BrandId] = @brandId, [IntroText] = @introText, [Url1] = @url1, [Url2] = @url2, [Url3] = @url3, [Url4] = @url4, [BumperPageHtml] = @bumperPageHtml, [BumperPageSkip] = @bumperPageSkip, [CustomHtml] = @customHtml, [HomepageTypeId] = @homepageTypeId, [IsPublished] = @isPublished, [LastModifiedByUserId] = @lastModifiedByUserId, [LastModifiedDate] = @lastModifiedDate WHERE HomepageId = @homepageId";
            }

            command.Parameters.Add(CreateParameter("@brandId", homepage.BrandId));
            command.Parameters.Add(CreateParameter("@introText", homepage.IntroText));
            command.Parameters.Add(CreateParameter("@url1", homepage.Url1));
            command.Parameters.Add(CreateParameter("@url2", homepage.Url2));
            command.Parameters.Add(CreateParameter("@url3", homepage.Url3));
            command.Parameters.Add(CreateParameter("@url4", homepage.Url4));
            command.Parameters.Add(CreateParameter("@bumperPageHtml", homepage.BumperPageHtml));
            command.Parameters.Add(CreateParameter("@bumperPageSkip", homepage.BumperPageSkip));
            command.Parameters.Add(CreateParameter("@customHtml", homepage.CustomHtml));
            command.Parameters.Add(CreateParameter("@homepageTypeId", homepage.HomepageTypeId));
            command.Parameters.Add(CreateParameter("@isPublished", homepage.IsPublished));
            command.Parameters.Add(CreateParameter("@lastModifiedByUserId", homepage.LastModifiedByUserId));
            command.Parameters.Add(CreateParameter("@lastModifiedDate", homepage.LastModifiedDate));

            if (homepage.IsNew)
            {
                homepage.HomepageId = Convert.ToInt32(ExecScalar(command));
            }
            else
            {
                command.Parameters.Add(CreateParameter("@homepageId", homepage.HomepageId));
                ExecuteCommand(command);
            }

            homepage.IsDirty = false;
            homepage.ChangedProperties.Clear();

            return(homepage);
        }
Example #2
0
        public static Homepage FindOne(HomepageFinder finder)
        {
            Homepage Homepage = HomepageMapper.Instance.FindOne(finder);

            return(Homepage ?? Empty);
        }
Example #3
0
 public static Homepage Update(Homepage homepage)
 {
     return(HomepageMapper.Instance.Update(homepage));
 }
Example #4
0
        public static Homepage Get(Nullable <Int32> HomepageId)
        {
            Homepage Homepage = HomepageMapper.Instance.Get(HomepageId);

            return(Homepage ?? Empty);
        }