Beispiel #1
0
        public async Task When_UpdateByIdAsync()
        {
            // Arrange

            var toDoData =
                new ToDoData
            {
                Description = _faker.Lorem.Paragraph(1)
            };

            toDoData.ToDoId =
                toDoData.Id;

            await _toDoDataContainer.CreateItemAsync(
                toDoData,
                new PartitionKey(toDoData.Id));

            toDoData.Description = _faker.Lorem.Paragraph(1);

            // Action

            await _toDoDataStore.UpdateByIdAsync(
                toDoData.Id,
                toDoData);

            // Assert

            toDoData =
                await _toDoDataContainer.ReadItemAsync <ToDoData>(
                    toDoData.Id,
                    new PartitionKey(toDoData.Id));

            toDoData.Should().NotBeNull();
        }
Beispiel #2
0
        public async Task When_ListAsync()
        {
            // Arrange


            for (var index = 0; index < 4; index++)
            {
                var toDoData =
                    new ToDoData
                {
                    Description = _faker.Lorem.Paragraph(1)
                };

                await _toDoDataContainer.CreateItemAsync(
                    toDoData,
                    new PartitionKey(toDoData.Id));
            }

            // Action

            var toDoDataList =
                await _toDoDataStore.ListAsync();

            // Assert

            toDoDataList.Should().NotBeNull();
            toDoDataList.Count().Should().BeGreaterThan(3);
        }
Beispiel #3
0
        public async Task When_DeleteByIdAsync()
        {
            // Arrange

            var toDoData =
                new ToDoData
            {
                Description = _faker.Lorem.Paragraph(1)
            };

            await _toDoDataContainer.CreateItemAsync(
                toDoData,
                new PartitionKey(toDoData.Id));

            // Action

            await _toDoDataStore.DeleteByIdAsync(
                toDoData.Id);

            // Assert

            Func <Task> action = async() =>
                                 await _toDoDataContainer.ReadItemAsync <ToDoData>(
                toDoData.Id,
                new PartitionKey(toDoData.Id));

            action.Should().Throw <CosmosException>()
            .And.StatusCode.Should().Be(404);
        }
Beispiel #4
0
        public object FindByID(string entityID, bool includeDeletedToDo)
        {
            ToDoData todoData = null;

            todoData = new ToDoData
            {
                AssignedToId = "535ad70ad2d8e912e857525c",
                CategoryId   = "532b64b1a381168abe000a7d",
                ClosedDate   = DateTime.UtcNow,
                CreatedById  = "532b678fa381168abe000ce8",
                CreatedOn    = DateTime.UtcNow,
                Description  = "test description",
                DueDate      = DateTime.UtcNow,
                StartTime    = DateTime.UtcNow,
                Duration     = 20,
                Id           = "532b6320a381168abe000877",
                PatientId    = "532b645fa381168abe0009e9",
                PriorityId   = (int)Priority.High,
                StatusId     = (int)Status.Met,
                Title        = "test title",
                UpdatedOn    = DateTime.UtcNow,
                DeleteFlag   = true
            };
            return(todoData);
        }
Beispiel #5
0
        public void UpdateToDo_Test()
        {
            ToDoData data = new ToDoData
            {
                Id          = "5400b215d433231f60c94119",
                StatusId    = (int)Status.Met,
                Description = "updated desc",
                Title       = "updated title",
                DueDate     = DateTime.UtcNow,
                StartTime   = System.DateTime.UtcNow,
                Duration    = 20,
                ClosedDate  = DateTime.UtcNow
            };
            PutUpdateToDoDataRequest request = new PutUpdateToDoDataRequest
            {
                Context        = context,
                ContractNumber = contractNumber,
                ToDoData       = data,
                UserId         = userId,
                Version        = version
            };

            ISchedulingDataManager cm = new StubToDoDataManager {
                Factory = new StubSchedulingRepositoryFactory()
            };
            PutUpdateToDoDataResponse response = cm.UpdateToDo(request);

            Assert.IsNotNull(response);
        }
Beispiel #6
0
        public object Insert(object newEntity)
        {
            PutInsertToDoDataRequest request = (PutInsertToDoDataRequest)newEntity;
            ToDoData todoData = request.ToDoData;
            string   id       = null;
            METoDo   meToDo   = null;

            try
            {
                if (todoData != null)
                {
                    meToDo = new METoDo(this.UserId, todoData.CreatedOn)
                    {
                        Id           = ObjectId.Parse("532b6320a381168abe000877"),
                        Status       = (Status)todoData.StatusId,
                        Priority     = (Priority)todoData.PriorityId,
                        Description  = todoData.Description,
                        Title        = todoData.Title,
                        LoweredTitle = todoData.Title != null?todoData.Title.ToLower() : null,
                                           DueDate       = todoData.DueDate,
                                           StartTime     = meToDo.StartTime,
                                           Duration      = meToDo.Duration,
                                           DeleteFlag    = false,
                                           AssignedToId  = ObjectId.Parse(todoData.AssignedToId),
                                           SourceId      = ObjectId.Parse(todoData.SourceId),
                                           ClosedDate    = todoData.ClosedDate,
                                           LastUpdatedOn = todoData.UpdatedOn
                    };
                }
                return(meToDo.Id.ToString());
            }
            catch (Exception) { throw; }
        }
Beispiel #7
0
        public object FindByExternalRecordId(string externalRecordId)
        {
            ToDoData data = null;

            try
            {
                using (SchedulingMongoContext ctx = new SchedulingMongoContext(_dbName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(Query.EQ(METoDo.ExternalRecordIdProperty, externalRecordId));
                    queries.Add(Query.EQ(METoDo.DeleteFlagProperty, false));
                    queries.Add(Query.EQ(METoDo.TTLDateProperty, BsonNull.Value));
                    IMongoQuery mQuery = Query.And(queries);
                    METoDo      mePN   = ctx.ToDos.Collection.Find(mQuery).FirstOrDefault();
                    if (mePN != null)
                    {
                        data = new ToDoData
                        {
                            Id = mePN.Id.ToString(),
                        };
                    }
                }
                return(data);
            }
            catch (Exception) { throw; }
        }
Beispiel #8
0
        private ToDo convertToToDo(ToDoData toDoData)
        {
            ToDo data = null;

            if (toDoData != null)
            {
                data = new ToDo
                {
                    AssignedToId = toDoData.AssignedToId,
                    CategoryId   = toDoData.CategoryId,
                    ClosedDate   = toDoData.ClosedDate,
                    CreatedById  = toDoData.CreatedById,
                    CreatedOn    = toDoData.CreatedOn,
                    Description  = toDoData.Description,
                    DueDate      = toDoData.DueDate,
                    StartTime    = toDoData.StartTime,
                    Duration     = toDoData.Duration,
                    Id           = toDoData.Id,
                    PatientId    = toDoData.PatientId,
                    PriorityId   = toDoData.PriorityId,
                    ProgramIds   = toDoData.ProgramIds,
                    StatusId     = toDoData.StatusId,
                    Title        = toDoData.Title,
                    UpdatedOn    = toDoData.UpdatedOn,
                    DeleteFlag   = toDoData.DeleteFlag
                };
            }
            return(data);
        }
        private void PopulateCategories()
        {
            List <string> categories = ToDoData.GetCategories();

            Category.DataSource = categories;
            Category.DataBind();
        }
Beispiel #10
0
        public object Update(object entity)
        {
            PutUpdateToDoDataRequest request = (PutUpdateToDoDataRequest)entity;
            ToDoData todoData = request.ToDoData;
            bool     result   = false;

            if (todoData != null)
            {
                METoDo meToDo = new METoDo(this.UserId, todoData.CreatedOn)
                {
                    Status       = (Status)todoData.StatusId,
                    Priority     = (Priority)todoData.PriorityId,
                    Description  = todoData.Description,
                    Title        = todoData.Title,
                    LoweredTitle = todoData.Title != null?todoData.Title.ToLower() : null,
                                       DueDate    = todoData.DueDate,
                                       StartTime  = todoData.StartTime,
                                       Duration   = todoData.Duration,
                                       ClosedDate = todoData.ClosedDate
                };
            }
            result = true;

            return(result);
        }
Beispiel #11
0
        public PostUpdateToDoResponse UpdateToDo(PostUpdateToDoRequest request)
        {
            try
            {
                if (request.ToDo == null)
                {
                    throw new Exception("The ToDo property cannot be null in the request.");
                }

                PostUpdateToDoResponse response = new PostUpdateToDoResponse();
                // [Route("/{Context}/{Version}/{ContractNumber}/Scheduling/ToDo/Update", "PUT")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Scheduling/ToDo/Update",
                                                                          DDSchedulingUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber), request.UserId);

                ToDoData data = new ToDoData
                {
                    Id           = request.ToDo.Id,
                    AssignedToId = request.ToDo.AssignedToId,
                    CategoryId   = request.ToDo.CategoryId,
                    Description  = request.ToDo.Description,
                    DueDate      = request.ToDo.DueDate,
                    StartTime    = request.ToDo.StartTime,
                    Duration     = request.ToDo.Duration,
                    PatientId    = request.ToDo.PatientId,
                    PriorityId   = request.ToDo.PriorityId,
                    ProgramIds   = request.ToDo.ProgramIds,
                    Title        = request.ToDo.Title,
                    StatusId     = request.ToDo.StatusId,
                    DeleteFlag   = request.ToDo.DeleteFlag,
                    ClosedDate   = request.ToDo.ClosedDate
                };

                PutUpdateToDoDataResponse dataDomainResponse =
                    client.Put <PutUpdateToDoDataResponse>(url, new PutUpdateToDoDataRequest
                {
                    ToDoData       = data,
                    Context        = "NG",
                    ContractNumber = request.ContractNumber,
                    Version        = request.Version,
                    UserId         = request.UserId,
                } as object);
                if (dataDomainResponse != null && dataDomainResponse.ToDoData != null)
                {
                    ToDo toDo = convertToToDo(dataDomainResponse.ToDoData);
                    // Call Patient DD to get patient details.
                    getPatient(request.Version, request.ContractNumber, request.UserId, client, toDo);
                    response.ToDo    = toDo;
                    response.Version = dataDomainResponse.Version;
                }
                return(response);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:UpdateToDo()::" + ex.Message, ex.InnerException);
            }
        }
Beispiel #12
0
        public void ReBuildToDoItems()
        {
            var dataList = ToDoDataManager.Data.todoList;

            todosParent.children.Clear();

            var groupsByDay = dataList.Where(item => item.state.Val == ToDoData.ToDoState.Done)
                              .GroupBy(item => item.finishTime.Date)
                              .OrderByDescending(item => item.Key);

            foreach (var group in groupsByDay)
            {
                TimeSpan totalTime = TimeSpan.Zero;
                foreach (var item in group)
                {
                    totalTime += item.UsedTime;
                }

                todosParent.Add(
                    new LabelView(group.Key.ToString("yyyy年MM月dd日 (共" + ToDoData.UsedTimeToString(totalTime) + ")"))
                    .FontSize(20).TextLowCenter());

                todosParent.Add(new SpaceView(4));


                foreach (var item in group.OrderByDescending(val => val.finishTime))
                {
                    todosParent.Add(new ToDoListItemView(item, RemoveFromParent, true));
                    todosParent.Add(new SpaceView(4));
                }
            }


            RefreshVisible();
        }
Beispiel #13
0
        public void InsertToDo_Test()
        {
            ToDoData data = new ToDoData
            {
                AssignedToId = "5325c822072ef705080d3491",
                CategoryId   = "53f51afed4332316fcdbeba3",
                Description  = "to do description 3.",
                DueDate      = System.DateTime.UtcNow,
                StartTime    = DateTime.UtcNow,
                Duration     = 20,
                Title        = "to do title 3.",
                PatientId    = "5325da01d6a4850adcbba4fa",
                PriorityId   = 0,
                ProgramIds   = new System.Collections.Generic.List <string> {
                    "5330920da38116ac180009d2", "532caae9a38116ac18000846"
                },
            };
            PutInsertToDoDataRequest request = new PutInsertToDoDataRequest
            {
                Context        = context,
                ContractNumber = contractNumber,
                ToDoData       = data,
                UserId         = userId,
                Version        = version
            };

            ISchedulingDataManager cm = new SchedulingDataManager {
                Factory = new SchedulingRepositoryFactory()
            };
            PutInsertToDoDataResponse response = cm.InsertToDo(request);

            Assert.IsNotNull(response);
        }
Beispiel #14
0
        public void UpdateToDo_Test()
        {
            ToDoData data = new ToDoData
            {
                Id           = "5400b215d433231f60c94119",
                AssignedToId = "5325c821072ef705080d3488",
                //CategoryId = "53f51b0ed4332316fcdbeba4",
                //Description = "updated desc",
                //DueDate = System.DateTime.UtcNow,
                //StartTime = DateTime.UtcNow,
                //Duration = 20,
                Title = "this is my updated title",
                // PatientId = "5325d9efd6a4850adcbba4c2",
                // PriorityId = 3,
                StatusId = 1,
                //ProgramIds = new System.Collections.Generic.List<string> { "532caae9a38116ac18000846" },
                DeleteFlag = true
            };
            PutUpdateToDoDataRequest request = new PutUpdateToDoDataRequest
            {
                Context        = context,
                ContractNumber = contractNumber,
                ToDoData       = data,
                UserId         = userId,
                Version        = version
            };

            ISchedulingDataManager cm = new SchedulingDataManager {
                Factory = new SchedulingRepositoryFactory()
            };
            PutUpdateToDoDataResponse response = cm.UpdateToDo(request);

            Assert.IsNotNull(response);
        }
    public static ToDoData ConvertToDoNote(this ToDoListCls cls, ToDoNote note, bool isHide)
    {
        cls.noteList.Remove(note);
        //AddToDoItem  里面有save
        var data = new ToDoData().Init(content: note.content, finished: new Property <bool>(false), isHide: isHide);

        cls.AddToDoItem(data);
        return(data);
    }
Beispiel #16
0
        //Will store the appropriate ToDoData object's ToDo list into myData, depending on which list you clicked on MainPage
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            ToDoData newstuff = e.Parameter as ToDoData;

            myData        = newstuff.ToDoItems;
            doneData      = newstuff.DoneItems;
            ListName.Text = newstuff.Title;
        }
Beispiel #17
0
        //When rename is clicked on the flyout menu, you can rename your list into something different
        private async void Rename_Click(object sender, RoutedEventArgs e)
        {
            NewNameBox.Text = "";
            ContentDialogResult result = await RenameDialog.ShowAsync();

            if (result == ContentDialogResult.Primary && NewNameBox.Text != "")
            {
                handledDat.Title = NewNameBox.Text;
            }
            handledDat = null;
        }
Beispiel #18
0
        //When you right click on a list item, you have the option to delete or rename it.
        private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            StackPanel listView = (StackPanel)sender;

            Fly.ShowAt(listView, e.GetPosition(listView));
            var a = ((FrameworkElement)e.OriginalSource).DataContext;

            StackPanel sta = sender as StackPanel;

            handledDat = sta.DataContext as ToDoData;
        }
 public static ToDoItemDTO ConvertObject(this ToDoData toDoData)
 {
     return(new ToDoItemDTO()
     {
         Id = toDoData.Id,
         UserId = toDoData.UserId,
         Describtion = toDoData.Describtion,
         IsChecked = toDoData.IsChecked,
         Date = toDoData.Date
     });
 }
Beispiel #20
0
 public SettingService()
 {
     try
     {
         this.ReadFile();
     }
     catch (Exception e)
     {
         this.ToDoDataList = ToDoData.CreateDefault();
         this.SaveFile();
     }
 }
Beispiel #21
0
        public DTO.PutUpdateToDoDataResponse UpdateToDo(DTO.PutUpdateToDoDataRequest request)
        {
            PutUpdateToDoDataResponse response = new PutUpdateToDoDataResponse();
            ISchedulingRepository     repo     = Factory.GetRepository(request, RepositoryType.ToDo);
            bool success = (bool)repo.Update(request);

            if (success)
            {
                ToDoData data = (ToDoData)repo.FindByID(request.ToDoData.Id, true);
                response.ToDoData = data;
            }
            return(response);
        }
Beispiel #22
0
        public DTO.PutInsertToDoDataResponse InsertToDo(DTO.PutInsertToDoDataRequest request)
        {
            PutInsertToDoDataResponse respone = new PutInsertToDoDataResponse();
            ISchedulingRepository     repo    = Factory.GetRepository(request, RepositoryType.ToDo);
            string toDoId = (string)repo.Insert(request);

            if (!string.IsNullOrEmpty(toDoId))
            {
                ToDoData data = (ToDoData)repo.FindByID(toDoId);
                respone.ToDoData = data;
            }
            return(respone);
        }
 public ToDoListItemView(ToDoData _item, Action <ToDoListItemView> _changeProperty, bool _showTime = false,
                         Action <ToDoData> _deleteAct = null)
     : base()
 {
     this.data           = _item;
     this.changeProperty = _changeProperty;
     this.showTime       = _showTime;
     this.deleteAct      = _deleteAct;
     container           = new HorizontalLayout("box");
     Add(container);
     Add(new SpaceView(4));
     BuildItem();
 }
Beispiel #24
0
        private void AddToDoToFoldoutView(ToDoData todoItem)
        {
            var itemToDoView = new ToDoListItemView(todoItem, (_) => RefreshStateWithView());

            itemToDoView.deleteAct = (_) =>
            {
                EnqueueCmd(() =>
                {
                    ToDoDataManager.RemoveProductToDoItem(productVersion, todoItem);
                    foldoutView.RemoveFoldoutView(itemToDoView);
                });
            };

            foldoutView.AddFoldoutView(itemToDoView);
        }
Beispiel #25
0
 public void SetDefaultAssignment(string userId, Schedule todoTemp, ToDoData todo)
 {
     try
     {
         // eng-1069
         if (!todoTemp.DefaultAssignment)
         {
             return;
         }
         todo.AssignedToId = userId;
     }
     catch (Exception ex)
     {
         throw new Exception("AD:ToDoActivationRule:SetDefaultAssignment()::" + ex.Message, ex.InnerException);
     }
 }
Beispiel #26
0
 public IActionResult Create(ToDoData toDoData)
 {
     try
     {
         toDoData.CreateDateTime = DateTime.Now;
         toDoData.IsRead         = false;
         _toDoDataService.Insert(toDoData);
     }
     catch (Exception e)
     {
         TempData.Put("Notification", new UiMessage(NotyType.error, "Create failed."));
         return(RedirectToAction("Index"));
     }
     TempData.Put("Notification", new UiMessage(NotyType.success, "Created."));
     return(RedirectToAction("Index"));
 }
Beispiel #27
0
        public object FindByID(string entityID, bool includeDeletedToDo)
        {
            ToDoData todoData = null;

            try
            {
                using (SchedulingMongoContext ctx = new SchedulingMongoContext(_dbName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    if (!includeDeletedToDo)
                    {
                        queries.Add(Query.EQ(METoDo.DeleteFlagProperty, false));
                    }
                    queries.Add(Query.EQ(METoDo.IdProperty, ObjectId.Parse(entityID)));
                    IMongoQuery mQuery = Query.And(queries);
                    METoDo      meToDo = ctx.ToDos.Collection.Find(mQuery).FirstOrDefault();
                    if (meToDo != null)
                    {
                        todoData = new ToDoData
                        {
                            AssignedToId     = meToDo.AssignedToId == null ? string.Empty : meToDo.AssignedToId.ToString(),
                            CategoryId       = meToDo.Category.ToString(),
                            ClosedDate       = meToDo.ClosedDate,
                            CreatedById      = meToDo.RecordCreatedBy.ToString(),
                            CreatedOn        = meToDo.RecordCreatedOn,
                            Description      = meToDo.Description,
                            DueDate          = meToDo.DueDate,
                            StartTime        = meToDo.StartTime,
                            Duration         = meToDo.Duration,
                            Id               = meToDo.Id.ToString(),
                            PatientId        = meToDo.PatientId == null ? string.Empty : meToDo.PatientId.ToString(),
                            PriorityId       = (int)meToDo.Priority,
                            ProgramIds       = Helper.ConvertToStringList(meToDo.ProgramIds),
                            StatusId         = (int)meToDo.Status,
                            Title            = meToDo.Title,
                            UpdatedOn        = meToDo.LastUpdatedOn,
                            ExternalRecordId = meToDo.ExternalRecordId,
                            DeleteFlag       = meToDo.DeleteFlag
                        };
                    }
                }
                return(todoData);
            }
            catch (Exception) { throw; }
        }
Beispiel #28
0
 public IActionResult Edit(ToDoData toDoData)
 {
     try
     {
         var _toDoData = _toDoDataService.Find(toDoData.Id);
         _toDoData.Title          = toDoData.Title;
         _toDoData.Description    = toDoData.Description;
         _toDoData.InsertDateTime = toDoData.InsertDateTime;
         _toDoDataService.Update(_toDoData);
     }
     catch (Exception e)
     {
         TempData.Put("Notification", new UiMessage(NotyType.error, "Updated Failed."));
         return(RedirectToAction("Index"));
     }
     TempData.Put("Notification", new UiMessage(NotyType.success, "Uptated."));
     return(RedirectToAction("Index"));
 }
        private List <ToDoItem> GetDisplay()
        {
            List <ToDoItem> todos        = ToDoData.GetToDoItems();
            List <ToDoItem> todosDisplay = new List <ToDoItem>();

            Debug.WriteLine(todos);

            if (NumberOfRecordsToDisplay > 0 && NumberOfRecordsToDisplay < todos.Count)
            {
                int index = 0;
                while (todosDisplay.Count < NumberOfRecordsToDisplay && index < todos.Count)
                {
                    if (string.IsNullOrWhiteSpace(CategoryFilter))
                    {
                        todosDisplay.Add(todos[index]);
                    }
                    else
                    {
                        if (todos[index].Category == CategoryFilter)
                        {
                            todosDisplay.Add(todos[index]);
                        }
                    }
                    index++;
                }
            }
            else if (!string.IsNullOrWhiteSpace(CategoryFilter))
            {
                int index = 0;
                while (index < todos.Count)
                {
                    if (todos[index].Category == CategoryFilter)
                    {
                        todosDisplay.Add(todos[index]);
                    }
                    index++;
                }
            }
            else
            {
                todosDisplay = todos;
            }
            return(todosDisplay);
        }
Beispiel #30
0
        public PutUpdateToDoDataResponse UpdateToDo(PutUpdateToDoDataRequest request)
        {
            PutUpdateToDoDataResponse response = new PutUpdateToDoDataResponse();

            try
            {
                ISchedulingRepository repo = Factory.GetRepository(request, RepositoryType.ToDo);
                bool success = (bool)repo.Update(request);
                if (success)
                {
                    ToDoData data = (ToDoData)repo.FindByID(request.ToDoData.Id, true);
                    response.ToDoData = data;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);;
        }