Exemple #1
0
            public async Task <BaseResponses <ProjectBidRequestDTO> > Handle(ProjectCommentRequest request, CancellationToken cancellationToken)
            {
                BaseResponses <ProjectBidRequestDTO> response = null;

                using (var trx = unitOfWork.BeginTransaction())
                {
                    try
                    {
                        if (request.Comment != null)
                        {
                            var user1 = userManager.FindByNameAsync(request.FreekancerName);
                            //ApplicationUser appuser = new ApplicationUser();
                            //appuser = user1.Result;
                            BidRequest bid = new BidRequest();
                            bid.BidPrice     = request.BidPrice;
                            bid.Comment      = request.Comment;
                            bid.ProjectId    = request.ProjectID.ToString();
                            bid.FreelancerId = user1.Result.Id;
                            await bidRequestService.Add(bid);
                        }
                        var project = await projectService.GetById(request.ProjectID.ToString());

                        var bidRequests = await bidRequestService.GetBidRequestsByProjectId(request.ProjectID.ToString());

                        var projectDetailsDTO = new ProjectBidRequestDTO()
                        {
                            Project = project
                        };
                        foreach (var item in bidRequests)
                        {
                            var user = await userManager.FindByIdAsync(item.FreelancerId.ToString());

                            projectDetailsDTO.BidRequests.Add(
                                new BidRequestDTO {
                                BidRequest = item,
                                FreeLancer = user
                            });
                        }
                        unitOfWork.SaveChanges();
                        response = new BaseResponses <ProjectBidRequestDTO>(projectDetailsDTO);
                    }
                    catch (RestException ex)
                    {
                        trx.Rollback();
                        response = new BaseResponses <ProjectBidRequestDTO>(ex.StatusCode, ex.Message);
                    }
                    return(response);
                }
            }
Exemple #2
0
            public async Task <BaseResponses <ProjectDetailsDTO> > Handle(ProjectDetailsRequest request, CancellationToken cancellationToken)
            {
                BaseResponses <ProjectDetailsDTO> response = null;

                using (var trx = unitOfWork.BeginTransaction())
                {
                    try
                    {
                        var project = await projectService.GetById(request.ProjectId);

                        var bidRequests = await bidRequestService.GetBidRequestsByProjectId(request.ProjectId);

                        var projectDetailsDTO = new ProjectDetailsDTO()
                        {
                            Project = project
                        };
                        foreach (var item in bidRequests)
                        {
                            var user = await userManager.FindByIdAsync(item.FreelancerId.ToString());

                            var country = await countryService.GetById(user.CountryId.ToString());

                            projectDetailsDTO.BidRequests.Add(new BidRequestDTO {
                                BidRequest = item, FreeLancer = user, Country = country
                            });
                        }
                        unitOfWork.SaveChanges();
                        response = new BaseResponses <ProjectDetailsDTO>(projectDetailsDTO);
                    }
                    catch (RestException ex)
                    {
                        trx.Rollback();
                        response = new BaseResponses <ProjectDetailsDTO>(ex.StatusCode, ex.Message);
                    }
                    return(response);
                }
            }