Пример #1
0
        public async Task <IActionResult> Update(SY_Notification model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var oldObj = await _SY_NotificationService.GetById(model.Id);

            if (oldObj == null)
            {
                ModelState.AddModelError("", "Bản ghi không tồn tại");
                return(View(model));
            }

            oldObj.Title       = model.Title;
            oldObj.Description = model.Description;

            var result = await _SY_NotificationService.Update(oldObj);

            if (result.isSuccess)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(model));
            }
        }
Пример #2
0
        public async Task <IActionResult> Create(SY_Notification model, bool SaveAndCountinue = false)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Id          = ObjectId.GenerateNewId().ToString();
            model.DateCreated = DateTime.Now;

            //Thực hiện thêm mới
            var result = await _SY_NotificationService.Create(model);

            if (result.isSuccess)
            {
                SendNotification(model);

                if (SaveAndCountinue)
                {
                    TempData["Success"] = "Thêm mới thành công";
                    return(RedirectToAction("Create"));
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", result.Message);
                return(View(model));
            }
        }
        public async Task <MessageReport> Update(SY_Notification model)
        {
            var query = new StringBuilder();

            query.AppendLine("{");
            query.AppendLine("'_id': { '$eq': '" + model.Id + "' }");
            query.AppendLine("}");

            return(await _SY_NotificationRepository.Update(MongoHelper.ConvertQueryStringToDocument(query.ToString()), model));
        }
Пример #4
0
        private async Task <MessageReport> SendNotification(SY_Notification model)
        {
            var obj = new OneSignalrMessage()
            {
                Description = model.Description,
                Id          = model.Id,
                PlayerIds   = new string[] {},
                Title       = "Thông báo: " + model.Title,
                UserIds     = "",
                View        = OneSignalConfig.NotificationPage
            };

            return(await _OS_PlayerService.SendNotification(obj));
        }
Пример #5
0
        public async Task <IActionResult> Create(SY_Notification model)
        {
            model = model == null ? new SY_Notification() : model;

            return(View(await Task.FromResult(model)));
        }
 public async Task <MessageReport> Create(SY_Notification model)
 {
     return(await _SY_NotificationRepository.Add(model));
 }