Exemplo n.º 1
0
        public void CropInsertTest()
        {
            CropServiceClient client = null;

             try
             {
                 //GetData test
                 client = new CropServiceClient();
                 Crop expected = new Crop();
                 expected.name = "Psenica";
                 expected.croptype = "MN98";
                 expected.fertilizingtime = new DateTime(2013, 04, 16);
                 expected.fieldfk = 2;
                 expected.harvesttime = new DateTime(2013, 05, 05);
                 expected.hillingtime = new DateTime(2013, 03, 03);
                 expected.illnessfk = 1;
                 expected.journalfk = 1;
                 expected.timeofplanting = new DateTime(2013, 02, 20);
                 expected.wateringfrequency = 2;
                 expected.wateringperiod = "mjesec";

                 int expectedid = client.InsertCropData(expected);

                 Crop actual = client.SelectCropById(expectedid);

                 Assert.AreEqual(expectedid, actual.cropid);
             }catch(Exception e){
                    Console.WriteLine("Exception encounter: {0}", e.Message);
             }
        }
Exemplo n.º 2
0
 // Return crop data by id
 public void getCropDataById(Action<CropModel> callback, int id)
 {
     CropServiceClient cropSvc = new CropServiceClient();
     getCropByIdCallback = callback;
     cropSvc.SelectCropByIdAsync(id);
     cropSvc.SelectCropByIdCompleted += new EventHandler
     <SelectCropByIdCompletedEventArgs>(cropSvc_SelectCropByIdCompleted);
 }
Exemplo n.º 3
0
 public void getAllCrops(Action<List<CropModel>> callback)
 {
     CropServiceClient cropSvc = new CropServiceClient();
     getAllCropsCallback = callback;
     cropSvc.SelectCropsAsync();
     cropSvc.SelectCropsCompleted += new EventHandler
     <SelectCropsCompletedEventArgs>(cropSvc_GetAllCrops);
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            CropServiceClient client = null;

            try
            {
                //GetData test
                client = new CropServiceClient();
                Crop c = client.SelectCropById(1);
                Console.WriteLine("Result: ");
                Console.WriteLine("name = {0}", c.name);

                Crop crop = new Crop();
                crop.name = "Hmelj";
                crop.croptype = "MN98";
                crop.fertilizingtime = new DateTime(2013, 04, 16);
                crop.fieldfk = 2;
                crop.harvesttime = new DateTime(2013, 05, 05);
                crop.hillingtime = new DateTime(2013, 03, 03);
                crop.illnessfk = 1;
                crop.journalfk = 1;
                crop.timeofplanting = new DateTime(2013, 02, 20);
                crop.wateringfrequency = 2;
                crop.wateringperiod = "mjesec";

                int id = client.InsertCropData(crop);

                Console.WriteLine("The WCF service called returned: ");

                //GetDataUsingDataContract test
                //CompositeType compositeType = new CompositeType();
                //compositeType.BoolValue = true;
                //compositeType.StringValue = "test";
                //CompositeType responseComposit = client.GetDataUsingDataContract(compositeType);

                //Console.WriteLine("The WCF service called returned: '{0}' '{1}'",
                //                    responseComposit.BoolValue, responseComposit.StringValue);

                Console.WriteLine("Press any key to close");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception encounter: {0}",
                                   e.Message);
                Console.WriteLine("Press any key to close");
                Console.ReadKey();
            }
            finally
            {
                if (null != client)
                {
                    client.Close();
                }
            }
        }
Exemplo n.º 5
0
 // Save crop data
 public void saveCropData(Func<int,int> callback, CropModel cropModel)
 {
     this.cropModel = cropModel;
     insertCropCallback = callback;
     Crop c = mapCropModelToCrop(cropModel);
     CropServiceClient cropSvc = new CropServiceClient();
     cropSvc.InsertCropDataAsync(c);
     cropSvc.InsertCropDataCompleted += new EventHandler
         <InsertCropDataCompletedEventArgs>(cropSvc_InsertCropDataCompleted);
 }
Exemplo n.º 6
0
        public void init()
        {
            //Insert Test data
            CropServiceClient client = new CropServiceClient();
            List<Crop> testCrops = new List<Crop>();

            Crop crop1 = new Crop();
            crop1.name = "Repica";
            crop1.croptype = "MN98";
            crop1.fertilizingtime = new DateTime(2013, 04, 16);
            crop1.fieldfk = 2;
            crop1.harvesttime = new DateTime(2013, 05, 05);
            crop1.hillingtime = new DateTime(2013, 03, 03);
            crop1.illnessfk = 1;
            crop1.journalfk = 1;
            crop1.timeofplanting = new DateTime(2013, 02, 20);
            crop1.wateringfrequency = 2;
            crop1.wateringperiod = "mjesec";

            Crop crop2 = new Crop();
            crop2.name = "Lubenica";
            crop2.croptype = "MN98";
            crop2.fertilizingtime = new DateTime(2013, 04, 16);
            crop2.fieldfk = 2;
            crop2.harvesttime = new DateTime(2013, 05, 05);
            crop2.hillingtime = new DateTime(2013, 03, 03);
            crop2.illnessfk = 1;
            crop2.journalfk = 1;
            crop2.timeofplanting = new DateTime(2013, 02, 20);
            crop2.wateringfrequency = 2;
            crop2.wateringperiod = "mjesec";

            testCrops.Add(crop1);
            testCrops.Add(crop2);

            foreach (Crop c in testCrops)
            {
                client.InsertCropData(c);
            }
        }
Exemplo n.º 7
0
 public void deleteCropById(int id)
 {
     CropServiceClient cropSvc = new CropServiceClient();
     cropSvc.DeleteCropDataAsync(id);
 }