Example #1
0
 public void SaveComplaint()
 {
     try
     {
         WebClient client = new WebClient();
         client.Headers["Content-type"] = "application/json";
         ConsoleTest.Models.complaintItem temp = new ConsoleTest.Models.complaintItem();
         //temp.complaintId = complaint.complaintId;
         temp.userId          = 1;
         temp.title           = "Rubbish Test";
         temp.details         = "Test Rubbish";
         temp.numLikes        = 2;
         temp.numComments     = 1;
         temp.picture         = "zascac";
         temp.complaintDate   = DateTime.Now;
         temp.location        = "dasdas";
         temp.latitude        = (float)0.323;
         temp.longitude       = (float)32.44;
         temp.category        = "pothole";
         temp.complaintStatus = "Solved";
         temp.date            = DateTime.Now;
         temp.isAnonymous     = 1;
         string     path       = @"C:\Users\Banka\Desktop\images.jpg";
         FileStream fs         = new FileStream(path, FileMode.Open);
         byte[]     PhotoBytes = new byte[fs.Length];
         fs.Read(PhotoBytes, 0, PhotoBytes.Length);
         temp.ImageByte = PhotoBytes;
         MemoryStream stream = new MemoryStream();
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ConsoleTest.Models.complaintItem));
         serializer.WriteObject(stream, temp);
         byte[] data = client.UploadData("http://127.0.0.1/Core.svc/SaveComplaint", "POST", stream.ToArray());
         stream     = new MemoryStream(data);
         serializer = new DataContractJsonSerializer(typeof(int));
         int result = (int)serializer.ReadObject(stream);
         Console.WriteLine("Save User Result : " + result);
         logger.warning("Exit TestConnection Method");
         Console.ReadLine();
     }
     catch (FaultException <ConsoleTest.CoreService.Bug> Fex)
     {
         logger.error("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
         logger.error("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
         Console.ReadLine();
     }
     finally
     {
         if (null != client)
         {
             client.Close();
         }
     }
 }
Example #2
0
 public void SaveComplaint()
 {
     try
     {
     WebClient client = new WebClient();
     client.Headers["Content-type"] = "application/json";
         ConsoleTest.Models.complaintItem temp = new ConsoleTest.Models.complaintItem();
         //temp.complaintId = complaint.complaintId;
         temp.userId = 1;
         temp.title = "Rubbish Test";
         temp.details = "Test Rubbish";
         temp.numLikes = 2;
         temp.numComments = 1;
         temp.picture = "zascac";
         temp.complaintDate = DateTime.Now;
         temp.location = "dasdas";
         temp.latitude = (float)0.323;
         temp.longitude = (float)32.44;
         temp.category = "pothole";
         temp.complaintStatus = "Solved";
         temp.date = DateTime.Now;
         temp.isAnonymous = 1;
         string path = @"C:\Users\Banka\Desktop\images.jpg";
         FileStream fs=new FileStream(path,FileMode.Open);
         byte[] PhotoBytes = new byte[fs.Length];
         fs.Read(PhotoBytes, 0, PhotoBytes.Length);
         temp.ImageByte = PhotoBytes;
         MemoryStream stream = new MemoryStream();
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ConsoleTest.Models.complaintItem));
         serializer.WriteObject(stream, temp);
         byte[] data = client.UploadData("http://127.0.0.1/Core.svc/SaveComplaint", "POST", stream.ToArray());
         stream = new MemoryStream(data);
         serializer = new DataContractJsonSerializer(typeof(int));
         int result = (int)serializer.ReadObject(stream);
         Console.WriteLine("Save User Result : " + result);
         logger.warning("Exit TestConnection Method");
         Console.ReadLine();
     }
     catch (FaultException<ConsoleTest.CoreService.Bug> Fex)
     {
         logger.error("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
         logger.error("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
         Console.ReadLine();
     }
     finally
     {
         if (null != client)
         {
             client.Close();
         }
     }
 }
Example #3
0
        public complaintItem GetCopy()
        {
            complaintItem copy = (complaintItem)this.MemberwiseClone();

            return(copy);
        }