Exemplo n.º 1
0
        public JsonNetResult SaveScreen(MarketingCampaignScreen screen)
        {
            var user = ConnectCmsRepository.SecurityRepository.GetLoggedInUser();

            ConnectCmsRepository.MarketingCampaignRepository.SaveMarketingCampaignScreen(user.PKID, screen);
            var adboardIds =
                ConnectCmsRepository.WelcomeTabletRepository.GetAdBoardsUsingCampaignScreen(screen.PKID).Select(x => x.PKID);

            Task.Run(() =>
            {
                foreach (var adboard in adboardIds)
                {
                    try
                    {
                        var callBackUrl = string.Format("{0}://{1}/adboard/NotifyAdBoardChanged?id={2}", Request.Url.Scheme,
                                                        Request.Url.Host, adboard);
                        using (var wc = new System.Net.WebClient())
                        {
                            wc.Headers.Add(System.Net.HttpRequestHeader.ContentType, "application/json; charset=utf-8");
                            wc.Encoding = Encoding.UTF8;
                            wc.UploadString(callBackUrl, "POST", "");
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                }
            });
            return(JsonNet(true));
        }
Exemplo n.º 2
0
        public void SaveMarketingCampaignScreen(int userId, MarketingCampaignScreen screen)
        {
            if (screen.PKID != 0)
            {
                var c1 = GetMarketingCampaignScreen(userId, screen.PKID).Include(x => x.MarketingCampaignScreenSections.Select(y => y.MarketingCampaignScreenSectionImageMaps)).FirstOrDefault();
                if (c1 == null)
                {
                    return;
                }

                c1.Name        = screen.Name;
                c1.Orientation = screen.Orientation;
                c1.Layout      = screen.Layout;
                c1.MarketingCampaignScreenSections.ToList()
                .ForEach(sec =>
                {
                    sec.MarketingCampaignScreenSectionImageMaps.ToList().ForEach(im =>
                    {
                        ProxylessContext.MarketingCampaignScreenSectionImageMaps.Remove(im);
                    });
                    ProxylessContext.MarketingCampaignScreenSections.Remove(sec);
                });
                c1.MarketingCampaignScreenSections.Clear();
                screen.MarketingCampaignScreenSections.ForEach(section =>
                {
                    var sec = new MarketingCampaignScreenSection
                    {
                        PKID = section.PKID,
                        TransitionDuration = section.TransitionDuration,
                        Ordinal            = section.Ordinal
                    };
                    section.MarketingCampaignScreenSectionImageMaps.ForEach(im => sec.MarketingCampaignScreenSectionImageMaps.Add(new MarketingCampaignScreenSectionImageMap
                    {
                        PKID    = im.PKID,
                        FKImage = im.FKImage,
                        Ordinal = im.Ordinal
                    }));

                    c1.MarketingCampaignScreenSections.Add(sec);
                });
            }
            else
            {
                Rp.ExecuteAction(() =>
                {
                    var user = ProxylessContext.ContactUsers.Include(x => x.UserRoleMaps.Select(y => y.UserRolePermissionTagMaps)).FirstOrDefault(x => x.PKID == userId);
                    if (user != null)
                    {
                        var role = user.UserRoleMaps.FirstOrDefault(x => x.UserRolePermissionTagMaps.Any());
                        if (role != null)
                        {
                            var permissions = role.UserRolePermissionTagMaps;
                            permissions.ForEach(
                                x =>
                                screen.MarketingCampaignScreenPermissionTagMaps.Add(new MarketingCampaignScreenPermissionTagMap()
                            {
                                FKPermissionTag = x.FKPermissionTag
                            }));
                        }
                    }

                    ProxylessContext.MarketingCampaignScreens.Add(screen);
                });
            }

            ProxylessContext.LogValidationFailSaveChanges(string.Format("CU|{0}", userId));
        }