예제 #1
0
        public async Task <IActionResult> Get()
        {
            var data = await rep.GetAllNewsAsync();

            await _hubContext.Clients.All.SendAsync("dataUpdated", data);

            return(Ok(new { Message = "Request Completed" }));
        }
예제 #2
0
        //public async Task CreateOneNews(int id, string title, string description, string content, string imageUrl, bool published)
        //{
        //    await Clients.All.SendAsync("NewsCreated", id, title, description,content, imageUrl, published);
        //}

        public async Task UpdateData(int id, string title, string description, string content, string imageUrl, bool published, string method)
        {
            if (method.Equals("C"))
            {
                await rep.AddOneNewsAsync(title, description, content, imageUrl, published);
            }
            else if (method.Equals("U"))
            {
                await rep.UpdateOneNewsAsync(id, title, description, content, imageUrl, published);
            }
            else if (method.Equals("D"))
            {
                await rep.DeleteOneNewsAsync(id);
            }
            IEnumerable <News> data = await rep.GetAllNewsAsync();

            await Clients.All.SendAsync("dataUpdated", data);
        }