Example #1
0
        public int InsertLoggingLanding(string userName, string pageName, LandingTypeEnum landingTypeEnum)
        {
            var landingTyp = DbContextCRM.LandingTypes.FirstOrDefault(s => s.Type == (int)landingTypeEnum);

            if (landingTyp == null)
            {
                landingTyp = new LandingType
                {
                    Created = DateTime.UtcNow,
                    Type    = (int)landingTypeEnum
                };
                DbContextCRM.LandingTypes.Add(landingTyp);
            }
            var landingpage = DbContextCRM.LandingPageNames.FirstOrDefault(s => s.PageName == pageName);

            if (landingpage == null)
            {
                landingpage = new LandingPageName
                {
                    Created  = DateTime.UtcNow,
                    PageName = pageName
                };
                DbContextCRM.LandingPageNames.Add(landingpage);
            }
            var user = !string.IsNullOrEmpty(userName) ?
                       DbContextCRM.AspNetUserse.FirstOrDefault(s => s.UserName == userName) : null;
            var loggingLandingPage = new LoggingLandingPage
            {
                LandingPageName = landingpage,
                LandingType     = landingTyp,
                Created         = DateTime.UtcNow,
                UserId          = user != null ? user.Id : string.Empty
            };

            DbContextCRM.LoggingLandingPages.Add(loggingLandingPage);
            return(DbContextCRM.SaveChanges());
        }
 protected BaseRepository()
 {
     DbContextCRM = new DbContextCRM();
 }