Beispiel #1
0
        public async Task <bool> DeleteCustomTaskAsync(string customTaskTitle)
        {
            var customTask = await _cosmosStore.FindAsync(customTaskTitle, customTaskTitle);

            var response = await _cosmosStore.RemoveAsync(customTask);

            return(response.IsSuccess);
        }
Beispiel #2
0
        public async Task <bool> DeletePost_Async(Guid postId)
        {
            var cosmoPost = await _cosmosStore.FindAsync(postId.ToString());

            var response = await _cosmosStore.RemoveAsync(cosmoPost);

            return(response.IsSuccess);
        }
        public async Task <bool> UpdateProject(string projectId, CosmosProjectDto updatedProject)
        {
            var oldProject = await _NoDb.FindAsync(projectId, projectId);

            if (oldProject != null)
            {
                oldProject.ProjectName = updatedProject.ProjectName;
                var result = await _NoDb.UpdateAsync(oldProject);

                return(result.IsSuccess);
            }
            return(false);
        }
Beispiel #4
0
        public async Task <bool> DeletePostAsync(Guid id)
        {
            var post = await cosmosStore.FindAsync(id.ToString());

            if (post == null)
            {
                return(false);
            }

            var response = await cosmosStore.RemoveAsync(x => x.Id == post.Id.ToString());

            return(response.IsSuccess);
        }
Beispiel #5
0
        private static async Task <string> PrepareExpectedResponseAsync(Guid flatForRentAnnouncementId, ICosmosStore <FlatForRentAnnouncementEntity> cosmosStore)
        {
            var flatForRentAnnouncementEntity = await cosmosStore.FindAsync(flatForRentAnnouncementId.ToString());

            var flatForRentAnnouncementResponse = new FlatForRentAnnouncementResponse(
                flatForRentAnnouncementEntity.Id,
                flatForRentAnnouncementEntity.Title,
                flatForRentAnnouncementEntity.SourceUrl,
                flatForRentAnnouncementEntity.CityId,
                flatForRentAnnouncementEntity.Created,
                flatForRentAnnouncementEntity.Description,
                flatForRentAnnouncementEntity.Price,
                FlatForRentAnnouncementProfile.ConvertToNumberOfRoomsEnum(flatForRentAnnouncementEntity.NumberOfRooms.ConvertToEnumeration()),
                flatForRentAnnouncementEntity.CityDistricts);
            var settings = new JsonSerializerSettings
            {
                Formatting       = Formatting.Indented,
                ContractResolver = new DefaultTestPlatformContractResolver
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                },
                Converters = new List <JsonConverter> {
                    new IsoDateTimeConverter(), new StringEnumConverter()
                }
            };

            return(JsonConvert.SerializeObject(flatForRentAnnouncementResponse, settings));
        }
Beispiel #6
0
        public async Task UpdateAsync(UserFlatForRentAnnouncementPreferenceUpdatedIntegrationEvent integrationEvent)
        {
            var flatForRentAnnouncementPreference = await _cosmosStore.FindAsync(integrationEvent.FlatForRentAnnouncementPreferenceId.ToString());

            var sameCityDistricts = flatForRentAnnouncementPreference.CityDistricts.All(integrationEvent.CityDistricts.Contains) &&
                                    flatForRentAnnouncementPreference.CityDistricts.Count == integrationEvent.CityDistricts.Count;

            if (flatForRentAnnouncementPreference.CityId != integrationEvent.CityId ||
                flatForRentAnnouncementPreference.PriceMin != integrationEvent.PriceMin ||
                flatForRentAnnouncementPreference.PriceMax != integrationEvent.PriceMax ||
                flatForRentAnnouncementPreference.RoomNumbersMin != integrationEvent.RoomNumbersMin ||
                flatForRentAnnouncementPreference.RoomNumbersMax != integrationEvent.RoomNumbersMax ||
                !sameCityDistricts)
            {
                flatForRentAnnouncementPreference.AnnouncementUrlsToSend = new List <string>();
            }

            flatForRentAnnouncementPreference.CityId         = integrationEvent.CityId;
            flatForRentAnnouncementPreference.PriceMin       = integrationEvent.PriceMin;
            flatForRentAnnouncementPreference.PriceMax       = integrationEvent.PriceMax;
            flatForRentAnnouncementPreference.RoomNumbersMin = integrationEvent.RoomNumbersMin;
            flatForRentAnnouncementPreference.RoomNumbersMax = integrationEvent.RoomNumbersMax;
            flatForRentAnnouncementPreference.CityDistricts  = integrationEvent.CityDistricts.ToList();

            var updateResult = await _cosmosStore.UpdateAsync(flatForRentAnnouncementPreference);

            if (!updateResult.IsSuccess)
            {
                throw updateResult.Exception;
            }
        }
Beispiel #7
0
        public async Task UpdateAsync(UserRoomForRentAnnouncementPreferenceUpdatedIntegrationEvent integrationEvent)
        {
            var roomForRentAnnouncementPreference = await _cosmosStore.FindAsync(integrationEvent.RoomForRentAnnouncementPreferenceId.ToString());

            var sameCityDistricts = roomForRentAnnouncementPreference.CityDistricts.All(integrationEvent.CityDistricts.Contains) &&
                                    roomForRentAnnouncementPreference.CityDistricts.Count == integrationEvent.CityDistricts.Count;

            if (roomForRentAnnouncementPreference.CityId != integrationEvent.CityId ||
                roomForRentAnnouncementPreference.PriceMin != integrationEvent.PriceMin ||
                roomForRentAnnouncementPreference.PriceMax != integrationEvent.PriceMax ||
                roomForRentAnnouncementPreference.RoomType != integrationEvent.RoomType ||
                !sameCityDistricts)
            {
                roomForRentAnnouncementPreference.AnnouncementUrlsToSend = new List <string>();
            }

            roomForRentAnnouncementPreference.CityId        = integrationEvent.CityId;
            roomForRentAnnouncementPreference.PriceMin      = integrationEvent.PriceMin;
            roomForRentAnnouncementPreference.PriceMax      = integrationEvent.PriceMax;
            roomForRentAnnouncementPreference.RoomType      = integrationEvent.RoomType;
            roomForRentAnnouncementPreference.CityDistricts = integrationEvent.CityDistricts.ToList();

            var updateResult = await _cosmosStore.UpdateAsync(roomForRentAnnouncementPreference);

            if (!updateResult.IsSuccess)
            {
                throw updateResult.Exception;
            }
        }
Beispiel #8
0
        public async Task <EbatchSheetVm> Handle(GetEbatchSheetQuery request, CancellationToken cancellationToken)
        {
            var ebatchSheet = await _cosmosStore.FindAsync(request.Id, Constants.EBATCH_SHEET_PARTITON_KEY);

            if (ebatchSheet != null)
            {
                var userRoles = _httpContext.HttpContext?.User?.FindAll("roles").Select(r => r.Value);
                if (userRoles.Contains(UserRole.AdminTeam))
                {
                    return(ebatchSheet.ToViewEntity());
                }
                else
                {
                    var states = userRoles.Select(x => MappingExtention.GetReviewStateByRole(x).Value);
                    if (states.Contains(ebatchSheet.CurrentState.Value))
                    {
                        return(ebatchSheet.ToViewEntity());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }

            //return ebatchSheet.ToViewEntity();
        }
Beispiel #9
0
        public async Task <FlatForRentAnnouncement> GetByIdAsync(Guid id)
        {
            var flatForRentAnnouncementEntity = await _cosmosStore.FindAsync(id.ToString());

            return(flatForRentAnnouncementEntity != null
                ? _mapper.Map <FlatForRentAnnouncementEntity, FlatForRentAnnouncement>(flatForRentAnnouncementEntity)
                : null);
        }
Beispiel #10
0
        public async Task <Order> GetOrderByIdAsync(Guid orderId)
        {
            var order = await _cosmosStore.FindAsync(orderId.ToString(), orderId.ToString());

            return(order == null ? null : new Order {
                Id = Guid.Parse(order.Id), Amount = order.Amount
            });
        }
Beispiel #11
0
        public async Task <Message> GetMessageByIdAsync(Guid messageId)
        {
            var messageCosmos = await _cosmosStore.FindAsync(messageId.ToString(), messageId.ToString());

            return(messageCosmos == null ? null : new Message {
                Id = Guid.Parse(messageCosmos.Id), Text = messageCosmos.Text
            });
        }
        public async Task <Post> GetPostByIdAsync(Guid postId)
        {
            var post = await _cosmosStore.FindAsync(postId.ToString(), postId.ToString());

            return(post == null ? null : new Post {
                Id = Guid.Parse(post.Id), Name = post.Name
            });
        }
Beispiel #13
0
        public async Task <Post> GetPostByIdAsync(Guid Id)
        {
            var getpostid = await _cosmosStore.FindAsync(Id.ToString());

            return(new Post {
                ID = Guid.Parse(getpostid.Id), Name = getpostid.Name
            });
        }
        public async Task Persist_Grant_That_Will_Expire_Fetch_SUCCESS()
        {
            var sql    = $"SELECT* FROM c where c.key = \"{_currentEntity.Key}\"";
            var entity = (await _persistedGrantCosmosStore.QuerySingleAsync(sql, feedOptions: new Microsoft.Azure.Documents.Client.FeedOptions
            {
                PartitionKey = new Microsoft.Azure.Documents.PartitionKey(_currentEntity.Key)
            }));

            entity.Should().NotBeNull();
            _currentEntity.Key.Should().Be(entity.Key);

            _currentEntity.Id = entity.Id;

            entity = await _persistedGrantCosmosStore.FindAsync(entity.Id, _currentEntity.Key);

            entity.Should().NotBeNull();
            entity.Key.Should().Be(_currentEntity.Key);
        }
        public async Task ExecuteAsync(MarkProcessAsSuccessfulCommand command)
        {
            var process = await _cosmosStore.FindAsync(command.Id);

            process.EndDateTime = command.EndDateTime;
            process.Status      = ProcessStatus.Succeeded;

            await _cosmosStore.UpdateAsync(process);
        }
        public async Task <bool> DeletePostAsync(Guid postId)
        {
            var post = await _cosmosStore.FindAsync(postId.ToString());

            if (post == null)
            {
                return(false);
            }
            return(true);
        }
Beispiel #17
0
        public async Task <Product> GetProductByIDAsync(Guid productID)
        {
            var product = await _cosmosStore.FindAsync(productID.ToString(), productID.ToString());

            return(product == null ? null : new Product {
                ProductID = Guid.Parse(product.ProductID),
                ProductCode = product.ProductCode,
                ProductName = product.ProductName
            });
        }
Beispiel #18
0
        public virtual async Task <ActionResult <T> > GetByIdAsync(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(BadRequest());
            }

            if (id == "0" || id == "new")
            {
                return(new OkObjectResult(new T()));
            }

            var result = await _cosmosStore.FindAsync(id, _environmentId);

            if (result == null)
            {
                return(NotFound());
            }
            return(new OkObjectResult(result));
        }
        public async Task <ActionResult <string> > AddTaskItem(string listId, string taskName)
        {
            var taskList = await _tasksCosmosStore.FindAsync(listId);

            taskList.Items.Add(new TaskItem {
                Name = taskName
            });

            var result = await _tasksCosmosStore.UpsertAsync(taskList);

            return(result.Entity.Id);
        }
Beispiel #20
0
        public async Task <Post> GetByIdAsync(Guid id)
        {
            var result = await _CosmosStore.FindAsync(id.ToString(), new Microsoft.Azure.Cosmos.PartitionKey(id.ToString()));

            if (result == null)
            {
                return(null);
            }
            return(new Post {
                Id = Guid.Parse(result.Id), Name = result.Name
            });
        }
Beispiel #21
0
        public async Task ExecuteAsync(MarkProcessAsFailedCommand command)
        {
            var process = await _cosmosStore.FindAsync(command.Id);

            process.EndDateTime    = command.EndDateTime;
            process.Status         = ProcessStatus.Failed;
            process.FailureDetails = new FailureDetails()
            {
                ErrorNumber  = command.ErrorNumber,
                ErrorMessage = command.ErrorMessage
            };

            await _cosmosStore.UpdateAsync(process);
        }
        public async Task <IActionResult> GetById(Guid id, CancellationToken cancellationToken)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("Invalid Person Id"));
            }

            var person =
                await _peopleCosmosStore.FindAsync(id.ToString(), cancellationToken : cancellationToken);

            if (person == null)
            {
                return(NotFound());
            }

            var response = new GetPersonResponse
            {
                Identifier = person.Id,
                Name       = person.Name,
            };

            return(Ok(response));
        }
        public async Task <bool> Evalute(string projectId, Evalution evalution)
        {
            var EvaluatedProject = await _NoDb.FindAsync(projectId, projectId);

            EvaluatedProject.Evalution = evalution;
            var result = await _NoDb.UpdateAsync(EvaluatedProject);

            return(result.IsSuccess);
        }
        public async Task <IActionResult> GetById(Guid id, CancellationToken cancellationToken)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("Invalid index Id"));
            }

            var index = await _indexCosmosStore.FindAsync(id.ToString());

            if (index == null)
            {
                return(NotFound());
            }

            var response = new GetIndexResponse
            {
                Identifier = index.Id,
                Name       = index.Name,
                Location   = index.Location,
                Enabled    = index.Enabled
            };

            return(Ok(response));
        }
Beispiel #25
0
        public async Task <Post> GetByIdAsync(Guid id)
        {
            var cosmosPost = await _cosmosStore.FindAsync(id.ToString());

            if (cosmosPost == null)
            {
                return(null);
            }

            return(new Post
            {
                Id = Guid.Parse(cosmosPost.Id.ToString()),
                Name = cosmosPost.Name
            });
        }
        public async Task <bool> AssignDone(string projectId, DoneViewModel model)
        {
            var project = await _NoDb.FindAsync(projectId, projectId);

            var done = new Done
            {
                Id          = Guid.NewGuid().ToString(),
                Descreption = model.Descreption,
                Name        = model.Name,
                StartDate   = model.StartDate,
                EndDate     = model.EndDate
            };

            project.Framework.Dones.Add(done);
            var result = await _NoDb.UpdateAsync(project);

            return(result.IsSuccess);
        }
Beispiel #27
0
        public async Task <string> Handle(UpdateEbatchSheetCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation(nameof(UpdateEbatchSheetCommandHandler) + "UPDATE_EBATCHSHEET: {requestId} - {@BODY} ", request.Id, request);

            var ebatchSheet = await _cosmosStore.FindAsync(request.Id, Constants.EBATCH_SHEET_PARTITON_KEY);

            var user = _httpContext.HttpContext?.User;

            if (ebatchSheet != null)
            {
                var currentState   = ebatchSheet.CurrentState;
                var requestedState = request.CurrentState;

                ebatchSheet.UpdateDataWithoutChangingState(request);

                if (!requestedState.Equals(currentState))
                {
                    if (user.IsInRole(UserRole.AdminTeam))
                    {
                        ebatchSheet.ChangeState(requestedState);
                    }
                    else
                    {
                        ebatchSheet.ProceedNextState(requestedState);
                    }
                }

                var result = await _cosmosStore.UpdateAsync(ebatchSheet);

                if (!currentState.Equals(result.Entity.CurrentState))
                {
                    await _ebatchSheetEmailSender.SendEmail(ebatchSheet);
                }
                return(request.Id);
            }
            else
            {
                var exception = new NotFoundException($"EBATCHSHEET", request.Id);
                _logger.LogError(exception, $"[UpdateEbatchSheetCommandHandler] Ebatchsheet {request.Id} not found");
                throw exception;
            }
        }
        public async Task <IActionResult> GetCustomer([FromRoute] string customerId)
        {
            var customer = await _cosmosStore.FindAsync(customerId, customerId);

            return(customer == null ? (IActionResult)NotFound() : Ok(customer));
        }
Beispiel #29
0
 public Task <Process> ExecuteAsync(GetProcessByIdQuery command, Process previousResult)
 {
     return(_cosmosStore.FindAsync(command.Id));
 }
Beispiel #30
0
 public async Task <CosmosPost> GetByIdAsync(string id)
 {
     return(await _cosmosStore.FindAsync(id));
 }