public void CreateTest()
        {
            //Arrange
            DBTaskMaterial taskMaterial = new DBTaskMaterial();
            var            Create       = new ModelLayer.Task();

            Create.id        = 1;
            Create.materials = new List <Tuple <Material, int> >();
            var item = Tuple.Create(new Material {
                id = 1
            }, 200);
            var item2 = Tuple.Create(new Material {
                id = 2
            }, 400);

            Create.materials.Add(item);
            Create.materials.Add(item2);


            //Act
            var succes = taskMaterial.Create(Create);

            //Assert
            Assert.IsTrue(succes);
        }
Exemplo n.º 2
0
 private void CreateTask_Click(object sender, RoutedEventArgs e)
 {
     ModelLayer.Task task = new ModelLayer.Task {
         name = TaskName.Text, description = TaskDescription.Text, houseNumber = "0", road = "Ukendt", zipcode = "Ukendt"
     };                                                                                                                                                               //TODO: Ændre det predefinerede adresse
     ViewModel.PostTask(task);
     PopupCreate.IsOpen = false;
     Tasks.ItemsSource  = ViewModel.Tasks;
 }
        public ModelLayer.Task CheckIfLocationTaskExist(LocationModel locationModel) //Finder den sidste i listen af tasks som passer bedst og returnerer den
        {
            int bigFound = 0;

            ModelLayer.Task returnTask = new ModelLayer.Task();

            List <ModelLayer.Task> tempTasks = Tasks;

            foreach (var task in tempTasks)
            {
                if (locationModel.address.postcode != null && task.zipcode != null)
                {
                    if (task.zipcode.ToLower() == locationModel.address.postcode.ToLower()) //Hvis postnummeret er ens
                    {
                        if (bigFound < 2)
                        {
                            bigFound   = 1;
                            returnTask = task;
                        }

                        if (locationModel.address.road != null && task.road != null)
                        {
                            if (task.road.ToLower() == locationModel.address.road.ToLower()) //Hvis postnummer og vej er ens
                            {
                                //Hvis postnummer og vej passer
                                if (bigFound < 3)
                                {
                                    bigFound   = 2;
                                    returnTask = task;
                                }

                                if (locationModel.address.house_number != null && task.houseNumber != null)
                                {
                                    if (task.houseNumber.ToLower() == locationModel.address.house_number.ToLower()) //Hvis postnummer, vej og husnummer alle passer sammen
                                    {
                                        //Hvis postnummer, vej og husnummer alle passer sammen
                                        bigFound   = 3;
                                        returnTask = task;
                                    }
                                }
                            }
                        }
                    }
                }

                if (bigFound < 1) //Hvis der ikke er nogen der passer, så tag den sidste
                {
                    returnTask = task;
                }
            }


            return(returnTask);
        }