コード例 #1
0
        public async Task HandleAsync(CreateNoteInSqliteCommand command)
        {
            using (var context = _factory.CreateContext())
            {
                var note = _mapper.MapTo <Note>(command);
                note.Id = Guid.NewGuid();
                note.NeedSynchronization   = true;
                note.StatusSynchronization = SynchronizationStatusEnum.NeedInsert;

                try
                {
                    var(lot, lat) = await _geolocationService.GeLocationAsync();

                    note.Latitude  = lat;
                    note.Longitude = lot;
                }
                catch (PermissionException)
                {
                }

                note.CreatedAt = DateTime.UtcNow;

                await context.AddAsync(note);

                await context.SaveChangesAsync();

                NPublisher.PublishIt(new NewNotesMessage(note));
            }
        }