Example #1
0
        static void Main(string[] args)
        {
            WebClient proxy = new WebClient();
            var result = proxy.DownloadData("http://*****:*****@"application/json;charset=utf-8";
            EmployeeDTO emp = new EmployeeDTO {Name="Sachin T",City="Mumbai",Id="rt2"};
            DataContractJsonSerializer ser1 = new DataContractJsonSerializer(typeof(EmployeeDTO));
            MemoryStream mw = new MemoryStream();
            var reader = new StreamReader(mw);
            ser1.WriteObject(mw,emp);
            mw.Position =0;
            var body = reader.ReadToEnd();
            var strmWriter = new StreamWriter(req.GetRequestStream());
            strmWriter.Write(body);
            var response = req.GetResponse();

            //proxy.UploadString("",)
            //proxy.UploadData("http://localhost:62671/Service1.svc/Employee", "POST", mw.ToArray());
            Console.WriteLine("Data Created");
            Console.ReadKey(true);
        }
Example #2
0
 public static void AddEmployee(EmployeeDTO e)
 {
     DataClasses1DataContext context = new DataClasses1DataContext();
           Employee emp = Converter.EmpDTOtoEmp(e);
           context.Employees.InsertOnSubmit(emp);
           context.SubmitChanges();
 }
Example #3
0
 public static Employee EmpDTOtoEmp(EmployeeDTO d)
 {
     return new Employee
        {
            EmployeeName = d.Name,
            EmployeeCity = d.City,
            EmployeeId = d.Id
        };
 }