コード例 #1
0
        public void GetToDos_Test()
        {
            string     contractNumber = "InHealth001";
            double     version        = 1.0;
            string     token          = "53fb6f20d6a4851b0ce14611";
            string     assignedToId   = "5325c821072ef705080d3488";
            string     patientId      = "";//"5325db20d6a4850adcbba84e";
            List <int> statusIds      = new System.Collections.Generic.List <int> {
                1
            };

            JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("Token: {0}", token));
            //[Route("/{Version}/{ContractNumber}/ToDo/AssignedTo/{AssignedToId}/Patient/{PatientId}/Status/{StatusIds}", "GET")]
            IRestClient client = new JsonServiceClient();
            //[Route("/{Version}/{ContractNumber}/Contact/{ContactId}/RecentPatients", "GET")]
            string url = string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Scheduling/ToDos",
                                       version,
                                       contractNumber,
                                       assignedToId,
                                       patientId,
                                       statusIds);
            GetToDosResponse response = client.Post <GetToDosResponse>(
                url, new GetToDosRequest
            {
                AssignedToId   = assignedToId,
                ContractNumber = contractNumber,
                PatientId      = patientId,
                StatusIds      = statusIds,
                Token          = token,
                UserId         = "5325c821072ef705080d3488",
                Version        = version
            } as object);

            Assert.IsNotNull(response);
        }
コード例 #2
0
ファイル: ToDoService.cs プロジェクト: MarcinMarczyk/ToDoList
        //checking
        public GetToDosResponse GetToDos()
        {
            var response = new GetToDosResponse();

            try
            {
                response.ToDos = _context.ToDo.Select(x => new ToDo
                {
                    Id          = x.Id,
                    Name        = x.Name,
                    Description = x.Description,
                    Category    = new Category {
                        Name = x.Category.Name
                    },
                    EventDate    = x.EventDate,
                    IsDone       = x.IsDone,
                    ReminderDate = x.ReminderDate,
                    Tag          = new DTO.Tags.Tag {
                        Name = x.Tag.Name
                    }
                }).ToList();
            }
            catch (Exception msg)
            {
                response.Errors.Add(msg.Message);
            }
            if (!response.IsOk)
            {
                return(response);
            }

            return(response);
        }
コード例 #3
0
ファイル: ToDoService.cs プロジェクト: MarcinMarczyk/ToDoList
        //checking
        public GetToDosResponse GetToDos(GetToDosRequest request)
        {
            var response = new GetToDosResponse();

            try
            {
                if (request.Id <= 0)
                {
                    response.Errors.Add("The Id value is 0 or lower");
                }
                else
                {
                    response.ToDos = _context.ToDo.Where(x => x.Id == request.Id).Select(x => new ToDo
                    {
                        Name     = x.Name,
                        Id       = x.Id,
                        Category = new Category {
                            Name = x.Category.Name
                        },
                        Description  = x.Description,
                        EventDate    = x.EventDate,
                        IsDone       = x.IsDone,
                        ReminderDate = x.ReminderDate,
                        Tag          = new DTO.Tags.Tag {
                            Name = x.Tag.Name
                        }
                    }).ToList();
                    if (!response.IsOk)
                    {
                        return(response);
                    }
                }
            }
            catch (Exception msg)
            {
                response.Errors.Add(msg.Message);
            }

            response.Errors.Add("Something went wrong");
            if (!response.IsOk)
            {
                return(response);
            }

            return(response);
        }
コード例 #4
0
        public void GetToDosTest()
        {
            SchedulingManager ngm = new SchedulingManager();

            GetToDosRequest request = new GetToDosRequest
            {
                Version        = version,
                ContractNumber = contractNumber,
                UserId         = userId,
                AssignedToId   = "5325c821072ef705080d3488",
                // FromDate = DateTime.Parse("9/1/2014 3:47:01 PM"),
                StatusIds = new List <int> {
                    1, 3
                }
            };

            GetToDosResponse             response = ngm.GetToDos(request);
            List <AppDomain.NG.DTO.ToDo> list     = response.ToDos;

            Assert.IsNotNull(list);
        }
コード例 #5
0
        public GetToDosResponse Post(GetToDosRequest request)
        {
            GetToDosResponse      response = new GetToDosResponse();
            SchedulingManager     toDoMgr  = new SchedulingManager();
            ValidateTokenResponse result   = null;

            try
            {
                request.Token = base.Request.Headers["Token"] as string;
                result        = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId = result.UserId;
                    response       = toDoMgr.GetToDos(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    toDoMgr.LogException(ex);
                }
            }
            finally
            {
                List <string> patientIds = new List <string>();
                patientIds.Add(request.PatientId);
                if (result != null)
                {
                    AuditHelper.LogAuditData(request, result.SQLUserId, patientIds, System.Web.HttpContext.Current.Request, request.GetType().Name);
                }
            }
            return(response);
        }
コード例 #6
0
        public GetToDosResponse GetToDos(GetToDosRequest request)
        {
            try
            {
                GetToDosResponse response    = new GetToDosResponse();
                List <ToDo>      toDosResult = null;
                //[Route("/{Context}/{Version}/{ContractNumber}/Scheduling/ToDos", "POST")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Scheduling/ToDos",
                                                                          DDSchedulingUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber), request.UserId);

                GetToDosDataResponse ddResponse =
                    client.Post <GetToDosDataResponse>(url, new GetToDosDataRequest
                {
                    Context         = "NG",
                    ContractNumber  = request.ContractNumber,
                    Version         = request.Version,
                    UserId          = request.UserId,
                    AssignedToId    = request.AssignedToId,
                    NotAssignedToId = request.NotAssignedToId,
                    CreatedById     = request.CreatedById,
                    PatientId       = request.PatientId,
                    StatusIds       = request.StatusIds,
                    CategoryIds     = request.CategoryIds,
                    PriorityIds     = request.PriorityIds,
                    FromDate        = request.FromDate,
                    Skip            = request.Skip,
                    Take            = request.Take,
                    Sort            = request.Sort
                } as object);

                if (ddResponse != null && ddResponse.ToDos != null)
                {
                    response.TotalCount = ddResponse.TotalCount;
                    toDosResult         = new List <ToDo>();
                    List <ToDoData> dataList        = ddResponse.ToDos;
                    var             distintPatients = dataList.GroupBy(p => p.PatientId).Select(grp => grp.FirstOrDefault()).ToList();
                    List <string>   patientIds      = distintPatients.Select(p => p.PatientId).ToList();
                    // Call Patient DD to get patient details.
                    Dictionary <string, PatientData> patients = getPatients(request.Version, request.ContractNumber, request.UserId, client, patientIds);

                    foreach (ToDoData n in dataList)
                    {
                        ToDo toDo = convertToToDo(n);
                        if (patients != null && !string.IsNullOrEmpty(n.PatientId))
                        {
                            PatientData pd;
                            if (patients.TryGetValue(n.PatientId, out pd))
                            {
                                toDo.PatientDetails = new PatientDetails
                                {
                                    Id            = pd.Id,
                                    FirstName     = pd.FirstName,
                                    LastName      = pd.LastName,
                                    MiddleName    = pd.MiddleName,
                                    PreferredName = pd.PreferredName,
                                    Suffix        = pd.Suffix
                                };
                            }
                        }
                        toDosResult.Add(toDo);
                    }
                }
                response.ToDos = toDosResult;
                return(response);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:GetToDos()::" + ex.Message, ex.InnerException);
            }
        }