コード例 #1
0
ファイル: AssetController.cs プロジェクト: crgolden/Inventory
        public async Task <IActionResult> PostAsset(
            [SwaggerParameter("The Asset", Required = true), FromBody, Required] JsonElement element,
            CancellationToken cancellationToken)
        {
            IActionResult result;
            var           model = element.ToModel <Asset>();

            if (model.Id != default)
            {
                ModelState.AddModelError(nameof(model), "Id must be empty");
                result = BadRequest(ModelState);
            }
            else
            {
                model.CreatedBy = Guid.Parse(User.FindFirstValue(Sub));
                var request = new CreateRequest <Asset>(nameof(MongoDB), model, _logger);
                await _mediator.Send(request, cancellationToken).ConfigureAwait(false);

                var notification = new CreateNotification <Asset, Guid>(model.Id, model);
                await _mediator.Publish(notification, cancellationToken).ConfigureAwait(false);

                result = Created(model);
            }

            return(result);
        }
コード例 #2
0
        private void createNotificationButton_Click(object sender, EventArgs e)
        {
            if (storeID == null)
            {
                throw new Exception("No storeId/placeId known");
            }

            CreateNotification notification = new CreateNotification()
            {
                StoreId = storeID,

                Message    = "Unicode message € î ï è ç blâÿãh - " + DateTime.Now.ToString(),
                Data       = "{\"dataId\" : 10}",
                MatchRange = 250,

                Timespans = null // new CreateNotificationV1.Timespan[] { new CreateNotificationV1.Timespan { Start = null, End = null } }
            };

            using (Connection conn = NewConnection())
            {
                string result = conn.CreateNotification(notification);

                if (notificationId == null)
                {
                    notificationId = result;
                }

                AddLogLine(string.Format("ID of the created notification: {0}", result));
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public Task <Unit> Handle(CreateRequest <T> request, CancellationToken cancellationToken, RequestHandlerDelegate <Unit> next)
        {
            if (request == default)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (next == default)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (!_options.UseScopedLogging)
            {
                return(Handle());
            }

            using (request.Scope)
            {
                return(Handle());
            }

            async Task <Unit> Handle()
            {
                var start = new CreateNotification <T>(request.Model, request.Logger);
                await _mediator.Publish(start, cancellationToken).ConfigureAwait(false);

                var response = await next().ConfigureAwait(false);

                var finish = new CreateNotification(request.Logger);
                await _mediator.Publish(finish, cancellationToken).ConfigureAwait(false);

                return(response);
            }
        }
コード例 #4
0
        /// <summary>
        /// Создать уведомление
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <BaseApiResponse> CreateNotificationAsync(CreateNotification model)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(validation);
            }

            if (!await Query <EccUser>().AnyAsync(x => x.Id == model.UserId))
            {
                return(new BaseApiResponse(false, "Пользователь не найден по указанному идентификатору"));
            }

            CreateHandled(new UserNotificationInteraction
            {
                UserId           = model.UserId,
                ReadOn           = null,
                TitleText        = model.Title,
                MessageText      = model.Text,
                NotificationType = model.Type,
                ObjectJson       = model.ObjectJSON,
            });

            return(await TrySaveChangesAndReturnResultAsync("Создано уведомление для пользователя"));
        }
コード例 #5
0
    public void OnDialogPopUpCallBack(string buttonIndex)
    {
        int index = System.Convert.ToInt16(buttonIndex);

        switch (index)
        {
        case 0:
            AndroidNative.RedirectToWebPage(urlString);
            RaiseOnOnDialogPopupComplete(MessageState.YES);

            if (PlayerPrefs.GetString("choice") == "classes")
            {
                CreatePopup.PressedYes();
            }
            else if (PlayerPrefs.GetString("choice") == "timer")
            {
                SceneManager.LoadScene("RelaxMode");
                CreateNotification.Notification("Break Time's up!", "Let's get back to studying", PlayerPrefs.GetInt("breakTime"));
            }

            break;

        case 1:
            RaiseOnOnDialogPopupComplete(MessageState.NO);
            break;
        }
        Destroy(gameObject);
    }
コード例 #6
0
 private static void AddNotificationScript(JobConfiguration jobConfiguration, List <SqlScript> output)
 {
     if (jobConfiguration.Notification != null)
     {
         var notification = new CreateNotification(output.Count + 1, jobConfiguration);
         output.Add(new SqlScript(notification.FullName, notification.Contents));
     }
 }
コード例 #7
0
        public async Task <ApiResult <bool> > Create(CreateNotification bundle)
        {
            var json = JsonConvert.SerializeObject(bundle);

            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            var url         = $"/api/Notification";
            var result      = await Create <bool>(url, httpContent);

            return(result);
        }
コード例 #8
0
        public Task Handle(CreateNotification <T, TId> notification, CancellationToken cancellationToken)
        {
            if (notification == default)
            {
                throw new ArgumentNullException(nameof(notification));
            }

            _cache.SetCacheEntry(notification.Key, notification.Value, _options);
            return(_database.StringSetAsync(notification.Key.ToString(), Serialize(notification.Value), flags: FireAndForget));
        }
コード例 #9
0
 public void STARTDATIMER()
 {
     PlayerPrefs.SetInt("paused", 0);
     ResetClock();
     StartCoroutine(TIMER());
     CreateNotification.Notification("Time's up!", "Try taking a break!", timer);
     resetButton.interactable  = true;
     studyButton.interactable  = false;
     pauseButton.interactable  = true;
     resumeButton.interactable = false;
     PlayerPrefs.SetInt("notificationCounter", 0);
 }
コード例 #10
0
        public async Task <ApiResult <bool> > Create(CreateNotification bundle)
        {
            var idRece = await _userManager.FindByNameAsync(bundle.NameReceiver);

            var notification = new Notification()
            {
                IdReceiver = idRece.Id,
                Name       = bundle.Name,
                Path       = bundle.Path,
                Time       = DateTime.Now,
            };

            _context.Notifications.Add(notification);
            await _context.SaveChangesAsync();

            return(new ApiSuccessResult <bool>());
        }
コード例 #11
0
 public void SetTimer()
 {
     // bring the user to a break pae when the timer is over, if he chooses to do so
     CreateNotification.Notification("Break time is over!", "Let's go back to studying", PlayerPrefs.GetInt("breakTime"));
 }
コード例 #12
0
        public async Task <IActionResult> PostCustomer(CreateNotification payload)
        {
            var result = await _mediatr.Send(payload);

            return(Ok(result));
        }
コード例 #13
0
 //This method is called as soon as the user clicks to enter break mode. It takes the time that they have set for break time and counts down that time.
 public void CreateBreakModeNotification()
 {
     CreateNotification.Notification("Break Time's Up!", "Let's get back to studying!", PlayerPrefs.GetInt("breakTime"));
 }
コード例 #14
0
        public async Task <IActionResult> Create(CreateNotification bundle)
        {
            var result = await _notificationApiClient.Create(bundle);

            return(Ok(result));
        }
コード例 #15
0
        public async Task <IActionResult> Create([FromBody] CreateNotification bundle)
        {
            var result = await _notificationService.Create(bundle);

            return(Ok(result));
        }