/// <summary> /// Deletes the address. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void DeleteAddress(Object sender, EventArgs e) { Button btn = (Button)sender; int index = (btn.Parent as DataListItem).ItemIndex; Account account = Profile.Account; if (account != null) { CustomerAddress ca = account.FindCustomerAddress((int)AddressList.DataKeys[index]); if (ca != null) { ca.Delete(); ca.AcceptChanges(); } } BindData(); }
public override void DoOperation() { try { //Validate Reques Header / Constants this.baseResponseMessage = ValidateInput(); if (!this.baseResponseMessage.header.IsSuccess) { throw new Exception(this.baseResponseMessage.header.ResponseMessage); } //Operation switch (this.request.Header.OperationTypes) { case (int)OperationType.OperationTypes.ADD: #region ADD long checkGuid = 0; this.customerAddress = new CustomerAddress { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, CITY = this.request.CITY, COUNTRY = this.request.COUNTRY, DESCRIPTION = this.request.DESCRIPTION, ZIPCODE = this.request.ZIPCODE }; //Add Data to Database checkGuid = CustomerAddress.Insert(this.customerAddress); this.response = new ResponseCustomerAddress { CUSTOMER_NUMBER = checkGuid, ZIPCODE = this.request.ZIPCODE, DESCRIPTION = this.request.DESCRIPTION, COUNTRY = this.request.COUNTRY, CITY = this.request.CITY, header = new ResponseHeader { IsSuccess = checkGuid == 0 ? false : true, ResponseCode = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS, ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.GET: #region GET customerAddress = CustomerAddress.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER); this.response = new ResponseCustomerAddress { CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER, CITY = customerAddress.CITY, COUNTRY = customerAddress.COUNTRY, DESCRIPTION = customerAddress.DESCRIPTION, ZIPCODE = customerAddress.ZIPCODE, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.DELETE: #region DELETE this.customerAddress = new CustomerAddress { CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, ZIPCODE = this.request.ZIPCODE, DESCRIPTION = this.request.DESCRIPTION, CITY = this.request.CITY, COUNTRY = this.request.COUNTRY, UPDATE_USER = this.request.UPDATE_USER }; if (CustomerAddress.Delete(this.customerAddress)) { this.response = new ResponseCustomerAddress { CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER, CITY = "", COUNTRY = "", DESCRIPTION = "", ZIPCODE = "", header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; } else { this.response = new ResponseCustomerAddress { CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER, CITY = customerAddress.CITY, COUNTRY = customerAddress.COUNTRY, DESCRIPTION = customerAddress.DESCRIPTION, ZIPCODE = customerAddress.ZIPCODE, header = new ResponseHeader { IsSuccess = false, ResponseCode = CommonDefinitions.ERROR_MESSAGE, ResponseMessage = CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR } }; } #endregion break; case (int)OperationType.OperationTypes.UPDATE: #region UPDATE this.customerAddress = new CustomerAddress { CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, ZIPCODE = this.request.ZIPCODE, DESCRIPTION = this.request.DESCRIPTION, CITY = this.request.CITY, COUNTRY = this.request.COUNTRY, UPDATE_USER = this.request.UPDATE_USER }; if (CustomerAddress.Update(this.customerAddress)) { this.response = new ResponseCustomerAddress { CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER, CITY = customerAddress.CITY, COUNTRY = customerAddress.COUNTRY, DESCRIPTION = customerAddress.DESCRIPTION, ZIPCODE = customerAddress.ZIPCODE, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; } else { this.response = new ResponseCustomerAddress { CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER, CITY = customerAddress.CITY, COUNTRY = customerAddress.COUNTRY, DESCRIPTION = customerAddress.DESCRIPTION, ZIPCODE = customerAddress.ZIPCODE, header = new ResponseHeader { IsSuccess = false, ResponseCode = CommonDefinitions.ERROR_MESSAGE, ResponseMessage = CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR } }; } #endregion break; default: break; } } catch (Exception ex) { log.Error(ex.Message); throw; } }