Esempio n. 1
0
        public void SendingCallJSONCategory_JSONConverted()
        {
            try
            {
                // Arrange
                var testString = "Test";
                CategoryEntity categoryEntity = new CategoryEntity
                {
                    CategoryId = Guid.NewGuid().ToString(),
                    Name = "TestTestTest"
                };
                CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, categoryEntity, null,
                    null);

                //Act
                PatientCall call = new PatientCall();

                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                //Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
Esempio n. 2
0
        public void SendingCallJSONCategory_JSONConverted()
        {
            try
            {
                // Arrange
                var            testString     = "Test";
                CategoryEntity categoryEntity = new CategoryEntity
                {
                    CategoryId = Guid.NewGuid().ToString(),
                    Name       = "TestTestTest"
                };
                CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, categoryEntity, null,
                                                             null);

                //Act
                PatientCall call = new PatientCall();

                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                //Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
Esempio n. 3
0
        public void SendingCallJSONCategoryChoiceDetail_JSONConverted()
        {
            // Arrange
            var testString = "Test";

            var detail = new DetailEntity()
            {
                DetailId = Guid.NewGuid().ToString(),
                Name     = "Mælk",
            };

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name     = "Kaffe",
                Details  = new List <DetailEntity> {
                    detail
                }
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name       = "Dinmor",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List <ChoiceEntity> {
                    choice
                }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, detail);

            try
            {
                //Act
                PatientCall call   = new PatientCall();
                var         callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
Esempio n. 4
0
        public void UpdatingCallJSON_CalledUpdated()
        {
            //Arrange
            // Arrange
            var testString = "Test";

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name     = "Morfin"
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name       = "Smertestillende",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List <ChoiceEntity> {
                    choice
                }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, null);

            //Act
            PatientCall call = new PatientCall();

            try
            {
                callEntity._id    = "5641c5dd02a93d27a8910f9c";
                callEntity.Status = (int)CallUtil.StatusCode.Canceled;
                call.UpdateCall(callEntity);
            }
            catch (Exception e)
            {
                // Assert
                Assert.Fail("No calls has been updated");
            }
        }
Esempio n. 5
0
        public static void MakeCall(CallEntity callEntity, UIViewController vc)
        {
            var category = callEntity.Category;
            var choice   = callEntity.Choice ?? "";
            var detail   = callEntity.Detail ?? "";

            var confirmAlertController = UIAlertController.Create(category + " " + choice + " " + detail, Strings.CallSendMessage, UIAlertControllerStyle.Alert);

            // When user confirms the service
            var okAction = UIAlertAction.Create(Strings.CallSend, UIAlertActionStyle.Destructive, action =>
            {
                ShowLoadingScreen(vc, Strings.SpinnerDataSending);

                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                    var callEntities = DataHandler.LoadCallsFromLocalDatabase(new LocalDB());

                    vc.InvokeOnMainThread(() =>
                    {
                        if (callEntities != null && callEntities.Length > 0)
                        {
                            // Check if the call already has been made, then return;
                            if (CallHasBeenMade(callEntities, callEntity))
                            {
                                return;
                            }
                        }

                        new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                        {
                            // Make the async patient call here
                            try
                            {
                                ICall patientCall = new PatientCall();
                                // Assign the callid with the returned MongoDB id
                                callEntity._id = patientCall.MakeCall(callEntity);

                                vc.InvokeOnMainThread(() =>
                                {
                                    // Call successfull, take the user to myCalls passing the viewcontroller and the requested call
                                    GoToMyCalls(vc, callEntity);
                                });
                            }
                            catch (Exception ex)
                            {
                                // Hide the loading screen
                                Console.WriteLine("ERROR making call: " + ex.Message);

                                vc.InvokeOnMainThread(() =>
                                {
                                    loadingOverlay.Hide();
                                    new UIAlertView(Strings.Error, Strings.ErrorSendingCall, null, Strings.OK, null).Show();
                                });
                            }
                        })).Start();
                    });
                })).Start();


                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                })).Start();
            });

            // When user cancels the service
            var cancelAction = UIAlertAction.Create(Strings.Cancel, UIAlertActionStyle.Cancel, action =>
            {
                // Do nothing.
            });

            confirmAlertController.AddAction(okAction);
            confirmAlertController.AddAction(cancelAction);

            // Display the alert
            vc.PresentViewController(confirmAlertController, true, null);
        }
Esempio n. 6
0
        // Fortryd kald
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            tableView.DeselectRow(indexPath, true);

            var regretAlertController = UIAlertController.Create(Strings.CallRegretTitle, Strings.CallRegretMessage, UIAlertControllerStyle.Alert);

            var regretAction = UIAlertAction.Create(Strings.OK, UIAlertActionStyle.Destructive, action =>
            {
                new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                {
                    // Get the selected call
                    var callEntity = CallEntities[indexPath.Row];

                    // Update status
                    callEntity.Status = (int)CallUtil.StatusCode.Canceled;

                    // Try update the call
                    try
                    {
                        // Put the async patient call here
                        ICall patientCall = new PatientCall();
                        patientCall.UpdateCall(callEntity);

                        vc.InvokeOnMainThread(() =>
                        {
                            // (Get a confirm message that the patient call was successfull)
                            new UIAlertView(Strings.CallRegretted, null, null, "OK", null).Show();

                            DataHandler.UpdateMyCallToLocalDatabase(new LocalDB(), callEntity);

                            // Reload data
                            SetCallEntities(callEntity);
                            tableView.ReloadData();
                        });
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("ERROR updaing call: " + ex.Message);

                        vc.InvokeOnMainThread(() =>
                        {
                            new UIAlertView(Strings.Error, Strings.ErrorSendingCall, null, "OK", null).Show();

                            return;
                        });
                    }
                })).Start();
            });

            // When user cancels the service
            var cancelAction = UIAlertAction.Create("Annullér", UIAlertActionStyle.Cancel, action =>
            {
                // Do nothing.
            });

            regretAlertController.AddAction(regretAction);
            regretAlertController.AddAction(cancelAction);

            // Display the alert
            vc.PresentViewController(regretAlertController, true, null);
        }
Esempio n. 7
0
        public void SendingCallJSONCategoryChoice_JSONConverted()
        {
            // Arrange
            var testString = "Test";

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name = "Morfin"
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name = "Smertestillende",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List<ChoiceEntity> { choice }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, null);

            try
            {
                //Act
                PatientCall call = new PatientCall();
                var callId = call.MakeCall(callEntity);

                Assert.IsTrue(!String.IsNullOrEmpty(callId));
            }
            catch (Exception ex)
            {
                // Assert
                Assert.Fail("Status Code not OK " + ex.Message);
            }
        }
Esempio n. 8
0
        public void UpdatingCallJSON_CalledUpdated()
        {
            //Arrange
            // Arrange
            var testString = "Test";

            var choice = new ChoiceEntity()
            {
                ChoiceId = Guid.NewGuid().ToString(),
                Name = "Morfin"
            };

            var category = new CategoryEntity()
            {
                CategoryId = Guid.NewGuid().ToString(),
                Name = "Smertestillende",
                //Picture = "http://multimedia.pol.dk/archive/00537/ITALY_CLONED_CHAMPI_537998a.jpg",
                Choices = new List<ChoiceEntity> { choice }
            };

            CallEntity callEntity = CallWrapper.WrapCall(CPRNUMMER, CallUtil.StatusCode.Active, category, choice, null);

            //Act
            PatientCall call = new PatientCall();

            try
            {
                callEntity._id = "5641c5dd02a93d27a8910f9c";
                callEntity.Status = (int) CallUtil.StatusCode.Canceled;
                call.UpdateCall(callEntity);
            }
            catch (Exception e)
            {
                // Assert
                Assert.Fail("No calls has been updated");
            }
        }