コード例 #1
0
        public JsonResult ProjectReports(AllProjectRequest prtReq)
        {
            try
            {
                List <AllProjectResponse> projectsList = null;
                if (prtReq != null)
                {
                    if (Request.Cookies["AUTH_PTEmail"] != null && Request.Cookies["AUTHADMIN"] != null && Request.Cookies["AUTHADMIN"].Value == "Admin")
                    {
                        prtReq.LoginMailID = "";
                    }

                    projectsList = CABusinessProjectTrackingAPIClient.GetHttpResponse <List <AllProjectResponse> >(prtReq, CABPTMethodConstants.ALLPROJECTS);
                }
                return(Json(JsonConvert.SerializeObject(projectsList)));
            }
            catch (Exception ex)
            {
                JsonExceptionResult jsonexc = new JsonExceptionResult();
                return(Json(JsonConvert.SerializeObject(new CABPTException(ex, out jsonexc))));
            }
        }
コード例 #2
0
            public async Task <BaseResponses <IEnumerable <ProjectManagementDTOcs> > > Handle(AllProjectRequest request, CancellationToken cancellationToken)
            {
                BaseResponses <IEnumerable <ProjectManagementDTOcs> > response = null;

                using (var trx = unitOfWork.BeginTransaction())
                {
                    try
                    {
                        var projects = await projectService.GetAll();

                        var projectDtos = new List <ProjectManagementDTOcs>();
                        foreach (var item in projects)
                        {
                            var user = await userManager.FindByIdAsync(item.OwnerId.ToString());

                            var data = new ProjectManagementDTOcs()
                            {
                                CreatedDate      = item.CreateDate,
                                MaxPrice         = item.MaxPrice,
                                MinPrice         = item.MinPrice,
                                ProjectName      = item.Title,
                                ProjectOwnerName = $"{user.Name} {user.SurName}",
                                ProjectId        = item.Id.ToString(),
                                Status           = item.Status
                            };
                            projectDtos.Add(data);
                        }
                        unitOfWork.SaveChanges();
                        response = new BaseResponses <IEnumerable <ProjectManagementDTOcs> >(projectDtos);
                    }
                    catch (RestException ex)
                    {
                        trx.Rollback();
                        response = new BaseResponses <IEnumerable <ProjectManagementDTOcs> >(ex.StatusCode, ex.Message);
                    }
                    return(response);
                }
            }