Example #1
0
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            bool rv = false; // return value

            var emp = new EmpEntity
            {
                MANDT   = "001",
                EMPID   = txtEmpID.Text.Trim(),
                EMPNAME = txtName.Text.Trim(),
                EMPADDR = txtAddress.Text.Trim()
            };

            var empService = new EmpService();

            if (isAddNewMode)
            {
                try {
                    rv = empService.Create(emp);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                rv = empService.Update(emp);
            }

            if (rv)
            {
                empBs.EndEdit();
                this.Close();
            }
        }
Example #2
0
        public bool Create(EmpEntity emp)
        {
            String payload = JsonConvert.SerializeObject(emp);

            // Call POST method
            var resp = restSharpHelper.Post("/zrest/employees/create", payload);

            if (!resp.IsSuccessful)
            {
                throw new Exception(resp.Content);
            }

            return(true);
        }
Example #3
0
        public bool Update(EmpEntity emp)
        {
            String payload = JsonConvert.SerializeObject(emp);

            // Call POST method
            var resource = String.Format("/zrest/employees/{0}", emp.EMPID);
            var resp     = restSharpHelper.Put(resource, payload);

            if (!resp.IsSuccessful)
            {
                throw new Exception(resp.Content);
            }

            return(true);
        }