Esempio n. 1
0
        public Result UpdateEmployee(WCFTransactionEntity employeeData)
        {
            var result = new Result()
            {
                IsValid = false
            };

            StoreProcedureCommand procedure = CreateProcedureCommand("dbo.UpdateEmployee");

            procedure.AppendGuid("EmpID", employeeData.EmpID);
            procedure.AppendNVarChar("Address", employeeData.Address);
            procedure.AppendNVarChar("EMail", employeeData.EMail);
            procedure.AppendNVarChar("Phone", employeeData.Phone);

            int resultValue = ExecuteCommand(procedure);

            if (resultValue == 0)
            {
                result.IsValid = true;
                result.Message = new List <string> {
                    "Employee updated successfully"
                };
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Here exception is catched but not killed as it throw FaultException
        /// </summary>
        /// <param name="employeeData"></param>
        /// <returns></returns>
        public Result AddEmployee(WCFTransactionEntity employeeData)
        {
            Result result = new Result();

            try
            {
                var buisnessLayer = BLFactory.CreateWCFTransactionEmployeeDemoBL();
                result = buisnessLayer.AddEmployee(employeeData);
            }
            catch (Exception ex)
            {
                throw new FaultException <Result>(result);
            }

            return(result);
        }
Esempio n. 3
0
        protected void Employee_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var     employeeID = new Guid(e.Keys[0].ToString());
            TextBox Address    = (TextBox)Employee.Rows[e.RowIndex].FindControl("txtAddress");
            TextBox EMail      = (TextBox)Employee.Rows[e.RowIndex].FindControl("txtEMail");
            TextBox Phone      = (TextBox)Employee.Rows[e.RowIndex].FindControl("txtPhone");

            var emp = new WCFTransactionEntity {
                EmpID = employeeID, Address = Address.Text, EMail = EMail.Text, Phone = Phone.Text
            };

            var service = new AF.Transaction.Sample.TransactionService.WCFTransactionDemoClient();
            var result  = service.UpdateEmployee(emp);

            Employee.EditIndex  = -1;
            Session["employee"] = null;
            BindEmployeeGrid();
        }
Esempio n. 4
0
        /// <summary>
        /// Here exception is catched & killed
        /// The return object contain bool property 'IsValid'
        /// The property set to false in catch; hence transaction would rollback
        /// </summary>
        /// <param name="employeeData"></param>
        /// <returns></returns>
        public Result UpdateEmployee(WCFTransactionEntity employeeData)
        {
            Result result = new Result();

            try
            {
                var buisnessLayer = BLFactory.CreateWCFTransactionEmployeeDemoBL();
                result = buisnessLayer.UpdateEmployee(employeeData);
            }
            catch (Exception ex)
            {
                result = new Result {
                    IsValid = false, Message = new List <String> {
                        "Error in update operation"
                    }
                };
            }

            return(result);
        }
Esempio n. 5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var employeeEntity = new WCFTransactionEntity();

            employeeEntity.EmpID   = Guid.NewGuid();
            employeeEntity.Name    = txtName.Text;
            employeeEntity.Address = txtAddress.Text;
            employeeEntity.Phone   = txtPhone.Text;
            employeeEntity.EMail   = txtEMail.Text;

            try
            {
                var service = new AF.Transaction.Sample.TransactionService.WCFTransactionDemoClient();
                var result  = service.AddEmployee(employeeEntity);
                Session["employee"] = null;
                BindEmployeeGrid();

                if (result.IsValid)
                {
                    lblMessage.ForeColor = Color.Black;
                    txtName.Text         = String.Empty;
                    txtAddress.Text      = String.Empty;
                    txtPhone.Text        = String.Empty;
                    txtEMail.Text        = String.Empty;
                    lblMessage.Text      = "Record added successfuly";
                }
                else
                {
                    lblMessage.ForeColor = Color.Red;
                    foreach (var msg in result.Message)
                    {
                        lblMessage.Text = msg + "<br/>";
                    }
                }
            }
            catch (Exception ex)
            {
                //Log Error
            }
        }
Esempio n. 6
0
        public Result UpdateEmployee(WCFTransactionEntity employeeData)
        {
            var data = DataFactory.CreateWCFTransactionEmployeeDemoDL();

            return(data.UpdateEmployee(employeeData));
        }