コード例 #1
0
        public async Task <bool> CreatePostAsync(Post post)
        {
            var cosmosPost = new CosmosPostDTO
            {
                Id   = post.Id.ToString(),
                Name = post.Name
            };

            var response = await _cosmosStore.AddAsync(cosmosPost);

            post.Id = Guid.Parse(cosmosPost.Id);

            return(response.IsSuccess);
        }
コード例 #2
0
        public async Task <T> Post(T update)
        {
            var time = DateTime.Now;

            update.DateLastUpdated = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0);
            var previousResource = (await List(update.ResourceID)).Where(record => record.ResourceID == update.ResourceID);

            if (previousResource.Count() > 0)
            {
                await DeleteMany(previousResource.Select(r => r.id).ToList());
            }
            var newProductUpdate = await _productStore.AddAsync(update);

            return(newProductUpdate);
        }
コード例 #3
0
        public Task AddAsync(RoomForRentAnnouncement roomForRentAnnouncement)
        {
            var roomForRentAnnouncementEntity =
                _mapper.Map <RoomForRentAnnouncement, RoomForRentAnnouncementEntity>(roomForRentAnnouncement);

            return(_cosmosStore.AddAsync(roomForRentAnnouncementEntity));
        }
コード例 #4
0
        public Task AddAsync(FlatForRentAnnouncement flatForRentAnnouncement)
        {
            var flatForRentAnnouncementEntity =
                _mapper.Map <FlatForRentAnnouncement, FlatForRentAnnouncementEntity>(flatForRentAnnouncement);

            return(_cosmosStore.AddAsync(flatForRentAnnouncementEntity));
        }
コード例 #5
0
        public async Task <RatingModel> ExecuteAsync(CreateRatingCommand command, RatingModel previousResult)
        {
            if (Convert.ToInt32(command.rating) < 1 || Convert.ToInt32(command.rating) > 5)
            {
                throw new RatingException($"Rating: {command.rating} should be between 1-5");
            }
            string productUrl = "https://serverlessohproduct.trafficmanager.net/api/GetProduct?productid=" + command.productId;
            var    product    = await GetProductAsync(productUrl);

            string userUrl = "https://serverlessohuser.trafficmanager.net/api/GetUser?userId=" + command.userId;
            var    user    = await GetUserAsync(userUrl);

            if (product.StatusCode == HttpStatusCode.OK && user.StatusCode == HttpStatusCode.OK)
            {
                var rating = new RatingModel
                {
                    UserId       = command.userId,
                    ProductId    = command.productId,
                    LocationName = command.locationName,
                    Rating       = command.rating,
                    UserNotes    = command.userNotes,
                    Timestamp    = DateTime.Now
                };
                return(await _cosmosStore.AddAsync(rating));
            }
            return(await FindErrorMessage(product, user));
        }
コード例 #6
0
 public async Task <TodoItem> Add(TodoItem entity)
 {
     entity.Id           = Guid.NewGuid().ToString();
     entity.Created      = DateTime.UtcNow;
     entity.LastModified = entity.Created;
     return(await store.AddAsync(entity));
 }
コード例 #7
0
        public async Task <bool> CreateProject(CreateProjectViewModel model)
        {
            var Project = new CosmosProjectDto()
            {
                Id          = Guid.NewGuid().ToString(),
                ProjectName = model.Name,
                ProjectLogo = null,
                Mark        = 0,
                Developer   = new List <Developer>()
                {
                },
                Evalution = 0,
                Framework = new Framework()
                {
                },
                ProjectPath = null,
                SuperVisior = new SuperVisor()
                {
                },
                Wiki = null
            };
            var result = await _NoDb.AddAsync(Project);

            return(result.IsSuccess);
        }
コード例 #8
0
ファイル: CosmosPostService.cs プロジェクト: Fardim/Tweetbook
        public async Task <bool> CreatePostAsync(Post post)
        {
            var response = await _cosmosStore.AddAsync(new CosmosPostDto { Id = Guid.NewGuid().ToString(), Name = post.Name });

            post.Id = Guid.Parse(response.Entity.Id);
            return(response.IsSuccess);
        }
コード例 #9
0
        public async Task <ReportTemplate> Post(ReportTemplate reportTemplate, VerifiedUserContext verifiedUser)
        {
            var template = reportTemplate;

            template.SellerID = verifiedUser.SellerID;
            var newTemplate = await _store.AddAsync(template);

            return(newTemplate);
        }
コード例 #10
0
        public async Task <bool> CreatePostAsync(Post post)
        {
            var createpost = new CosmosPostDto {
                Id   = Guid.NewGuid().ToString(),
                Name = post.Name,
            };
            var create = await _cosmosStore.AddAsync(createpost);

            return(create.IsSuccess);
        }
コード例 #11
0
        public async Task <ReportTemplate> Post(ReportTemplate reportTemplate, DecodedToken decodedToken)
        {
            var me = await _oc.Me.GetAsync(accessToken : decodedToken.AccessToken);

            var template = reportTemplate;

            template.SellerID = me?.Seller?.ID;
            var newTemplate = await _store.AddAsync(template);

            return(newTemplate);
        }
コード例 #12
0
        public async Task <bool> CreatePost(Post post)
        {
            var cosmosPost = new CosmosPostDTO
            {
                Id   = Guid.NewGuid().ToString(),
                Name = post.Name
            };
            var result = await _cosmosStore.AddAsync(cosmosPost);

            return(result.IsSuccess);
        }
コード例 #13
0
        public async Task <bool> CreatePostAsync(Post postToCreate)
        {
            var cosmposPost = new CosmosPostDto()
            {
                Id   = Guid.NewGuid().ToString(),
                Name = postToCreate.Name
            };
            var response = await cosmosStore.AddAsync(cosmposPost);

            return(response.IsSuccess);
        }
コード例 #14
0
        public async Task <IActionResult> AddCrypto([FromForm] CryptoViewModel cryptoToAdd)
        {
            if (cryptoToAdd.valueUSD != null)
            {
                cryptoToAdd.valueBTC = (double.Parse(cryptoToAdd.valueUSD) / 7000).ToString();
                cryptoToAdd.valueETH = (double.Parse(cryptoToAdd.valueUSD) / 283).ToString();
            }

            await _cosmosStore.AddAsync(cryptoToAdd);

            return(RedirectToAction("Index"));
        }
コード例 #15
0
        public async Task RemoveByExpressionRemoves()
        {
            // Arrange
            foreach (var i in Enumerable.Range(0, 10))
            {
                var id         = Guid.NewGuid().ToString();
                var addedDummy = new Dummy
                {
                    Id   = id,
                    Name = "Test " + i
                };
                await _dummyStore.AddAsync(addedDummy);
            }

            // Act
            var result = await _dummyStore.RemoveAsync(x => x.Name.Contains("Test"));

            // Assert
            Assert.True(result.IsSuccess);
            Assert.Empty(result.FailedEntities);
        }
コード例 #16
0
        public async Task <bool> AddPost(Post createdPost)
        {
            var cosmosPost = new CosmosPostDto()
            {
                //Id = createdPost.Id.ToString(),
                Id   = Guid.NewGuid().ToString(),
                Name = createdPost.Name
            };
            var response = await cosmosStore.AddAsync(cosmosPost);

            return(response.IsSuccess);
        }
コード例 #17
0
        public async Task <bool> AddAsync(Post post)
        {
            var cosmosPostDto = new CosmosPostDto
            {
                Id   = Guid.NewGuid().ToString(),
                Name = post.Name
            };

            var added = await _cosmosStore.AddAsync(cosmosPostDto);

            return(added.IsSuccess);
        }
コード例 #18
0
ファイル: CosmosPostService.cs プロジェクト: arpi77/MyTweets
        public async Task <bool> CreateAsync(Post newPost)
        {
            var cosmosPostDto = new CosmosPostDto()
            {
                Id   = Guid.NewGuid().ToString(),
                Name = newPost.Name
            };

            var cosmosResponse = await _cosmosStore.AddAsync(cosmosPostDto);


            return(cosmosResponse.IsSuccess);
        }
コード例 #19
0
        public async Task <bool> CreateCustomTaskAsync(CustomTask customTask)
        {
            var cosmosCustomTask = new CosmosCustomTaskDto
            {
                Title       = customTask.Title,
                Description = customTask.Description
            };

            var response = await _cosmosStore.AddAsync(cosmosCustomTask);

            customTask.Title = cosmosCustomTask.Title;
            return(response.IsSuccess);
        }
コード例 #20
0
        public async Task ExecuteAsync(CreateProcessCommand command)
        {
            var process = new Process()
            {
                Id                     = command.Id,
                ProcessName            = command.ProcessName,
                InitiatingResourceName = command.InitiatingResourceName,
                StartDateTime          = command.StartDateTime,
                Status                 = ProcessStatus.InProgress
            };

            await _cosmosStore.AddAsync(process);
        }
コード例 #21
0
        public async Task <bool> CreateMessageAsync(Message message)
        {
            var messageCosmos = new MessageCosmos
            {
                Id   = Guid.NewGuid().ToString(),
                Text = message.Text
            };

            var response = await _cosmosStore.AddAsync(messageCosmos);

            message.Id = Guid.Parse(messageCosmos.Id);
            return(response.IsSuccess);
        }
コード例 #22
0
        public async Task <bool> CreateOrderAsync(Order order)
        {
            var cosmosOrder = new CosmosOrderDto
            {
                Id     = Guid.NewGuid().ToString(),
                Amount = order.Amount
            };

            var response = await _cosmosStore.AddAsync(cosmosOrder);

            order.Id = Guid.Parse(cosmosOrder.Id);
            return(response.IsSuccess);
        }
コード例 #23
0
        public async Task <string> Handle(CreateEbatchSheetCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("CREATE_NEW_EBATCHSHEET : {@request} ", request);

            var newEbatch = new EbatchSheet();

            newEbatch.Create(request);

            await _cosmosStore.AddAsync(newEbatch);

            await _ebatchSheetEmailSender.SendEmail(newEbatch);

            return(newEbatch.Id);
        }
コード例 #24
0
        public async Task <bool> CreateProductAsync(Product product)
        {
            var productCosmos = new CosmosProduct
            {
                ProductID   = Guid.NewGuid().ToString(),
                ProductName = product.ProductName,
                ProductCode = product.ProductCode
            };

            var response = await _cosmosStore.AddAsync(productCosmos);

            product.ProductID = Guid.Parse(productCosmos.ProductID);

            return(response.IsSuccess);
        }
コード例 #25
0
        private static async Task InsertFlatForRentAnnouncementEntityAsync(ICosmosStore <FlatForRentAnnouncementEntity> cosmosStore)
        {
            var flatForRentAnnouncementEntity = new FlatForRentAnnouncementEntity
            {
                Id               = Guid.NewGuid(),
                Title            = "GetFlatForRentAnnouncements",
                SourceUrl        = "http://sourceUrl",
                CityId           = CityOptions.City.Id,
                Created          = DateTimeOffset.UtcNow,
                Description      = "Description",
                Price            = 1000,
                NumberOfRooms    = NumberOfRooms.One,
                CityDistricts    = CityDistrictOptions.CityDistricts.Select(x => x.Id),
                CosmosEntityName = nameof(FlatForRentAnnouncement)
            };

            await cosmosStore.AddAsync(flatForRentAnnouncementEntity);
        }
コード例 #26
0
        private static async Task InsertRoomForRentAnnouncementEntityAsync(ICosmosStore <RoomForRentAnnouncementEntity> cosmosStore)
        {
            var roomForRentAnnouncementEntity = new RoomForRentAnnouncementEntity
            {
                Id               = Guid.NewGuid(),
                Title            = "GetRoomForRentAnnouncements",
                SourceUrl        = "http://sourceUrl",
                CityId           = CityOptions.City.Id,
                Created          = DateTimeOffset.UtcNow,
                Description      = "Description",
                Price            = 1000,
                CityDistricts    = CityDistrictOptions.CityDistricts.Select(x => x.Id),
                RoomTypes        = new [] { RoomType.Single },
                CosmosEntityName = nameof(RoomForRentAnnouncement)
            };

            await cosmosStore.AddAsync(roomForRentAnnouncementEntity);
        }
コード例 #27
0
        public async Task <Family> AddFamily(Family family)
        {
            try
            {
                var id = Guid.NewGuid().ToString("D");

                family.Id           = id;
                family.PartitionKey = PartitionKey.Generate("R", id, 1000);

                return(await store.AddAsync(family));
            }
            catch (Exception ex)
            {
                _logger.LogError(@$ "Adding item, LastName:{family.LastName} failed \n\r{ex.ToString()}");
            }

            return(family);
        }
        public async Task Persist_Grant_That_Will_Expire()
        {
            var ttl = 5; // 2 seconds

            _currentEntity = new PersistedGrantEntity
            {
                Key          = NewGuidS,
                ClientId     = NewGuidS,
                CreationTime = DateTime.UtcNow,
                Data         = NewGuidS,
                Expiration   = DateTime.UtcNow.AddSeconds(ttl),
                Type         = NewGuidS,
                TTL          = ttl
            };


            var response = await _persistedGrantCosmosStore.AddAsync(_currentEntity);

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.CosmosOperationStatus.Should().Be(CosmosOperationStatus.Success);
        }
コード例 #29
0
        public async Task <string> CreateArtist(Artist artist)
        {
            var artistId = Guid.NewGuid().ToString("D");

            try
            {
                var art = new Artist
                {
                    ArtistId = Guid.NewGuid().ToString("D"),
                    //PartitionKey = PartitionKeyGenerator.Create("R", artistId, 1000),
                    Name   = artist.Name,
                    Status = artist.Status
                };
                await Store.AddAsync(art);

                return(art.ArtistId.ToString());
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }
コード例 #30
0
        public async Task AddAsync(UserRoomForRentAnnouncementPreferenceCreatedIntegrationEvent integrationEvent)
        {
            var roomForRentAnnouncementPreference = new RoomForRentAnnouncementPreference
            {
                Id            = integrationEvent.RoomForRentAnnouncementPreferenceId,
                UserId        = integrationEvent.UserId,
                UserEmail     = integrationEvent.UserEmail,
                CityId        = integrationEvent.CityId,
                ServiceActive = integrationEvent.ServiceActive,
                AnnouncementSendingFrequency = integrationEvent.AnnouncementSendingFrequency,
                PriceMin         = integrationEvent.PriceMin,
                PriceMax         = integrationEvent.PriceMax,
                RoomType         = integrationEvent.RoomType,
                CityDistricts    = integrationEvent.CityDistricts.ToList(),
                CosmosEntityName = nameof(RoomForRentAnnouncementPreference)
            };
            var addResult = await _cosmosStore.AddAsync(roomForRentAnnouncementPreference);

            if (!addResult.IsSuccess)
            {
                throw addResult.Exception;
            }
        }