Exemplo n.º 1
0
        public HttpResponseMessage Post(NewsSentPostModel model)
        {
            List <string> PlayerIds = GetPlayerIds(model.Regions);

            if (PlayerIds.Count > 0)
            {
                var news = newsSvc.Load(model.NewsId);
                if (news != null)
                {
                    OneSignalNotification.SendNotification(news.Title, PlayerIds.ToArray(), news.ID);
                    newsSentSvc.Create(model);
                }
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemplo n.º 2
0
        public List <NewsSent> Create(NewsSentPostModel model)
        {
            try
            {
                List <NewsSent> finalList = new List <NewsSent>();

                var sendDate = DateTime.Now;
                foreach (var item in model.Regions)
                {
                    finalList.Add(Save(new NewsSent()
                    {
                        NewsID      = model.NewsId,
                        UserGroupId = item,
                        SentDate    = sendDate
                    }));
                }

                return(finalList);
            }
            catch
            {
                return(new List <NewsSent>());
            }
        }