Ejemplo n.º 1
0
        /// <summary>
        ///     Sign up a new account of customer
        /// </summary>
        /// <param name="customerJson"></param>
        /// <returns></returns>
        public JsonRespone SignUp(CustomerJson customerJson)
        {
            var customer = new Customer
            {
                FirstName = customerJson.FirstName,
                LastName = customerJson.LastName,
                Sex = customerJson.Sex,
                Address = customerJson.Address,
                BirthDay = DateTime.ParseExact(customerJson.BirthDay, Dictionary.DATE_FORMAT, null),
                Email = customerJson.Email,
                Phone = customerJson.Phone,
                UserName = customerJson.UserName,
                Password = customerJson.Password
            };

            var srvDao = NinjectKernelFactory.Kernel.Get<ICustomerDataAccess>();
            using (var tr = TransactionsFactory.CreateTransactionScope())
            {
                try
                {
                    srvDao.Save(customer);
                    m_authenticationJsonRespone.Message = Dictionary.MSG_SUCCESS;
                    tr.Complete();
                    return m_authenticationJsonRespone;
                }
                catch (Exception)
                {
                    m_authenticationJsonRespone.Message = Dictionary.MSG_FAILED;
                    return m_authenticationJsonRespone;
                }
            }
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SetErrorMessages();
     EnableValidator(false);
     m_customerId = int.Parse(Request.QueryString["RequestId"]);
     m_customer = ClientServiceFactory.CustomerService.GetCustomerById(m_customerId);
     if (Page.IsPostBack) return;
     if (m_customer != null)
     {
         txtCustomer.Text = Dictionary.CUSTOMER_ADMIN_EDIT_HEADER;
         txtFirstName.Text = m_customer.FirstName;
         txtLastName.Text = m_customer.LastName;
         DropDownList_Sex.SelectedValue = m_customer.Sex;
         txtBirthday.Text = m_customer.BirthDay.ToString(Dictionary.DATE_FORMAT);
         txtAddress.Text = m_customer.Address;
         txtEmail.Text = m_customer.Email;
         txtPhone.Text = m_customer.Phone;
         txtUsername.Text = m_customer.UserName;
         txtPassword.Text = m_customer.Password;
         s_rowVersion = m_customer.RowVersion;
     }
     else if (m_customerId == -4438)
     {
         txtCustomer.Text = Dictionary.COMPANY_ADMIN_NEW_HEADER;
     }
     else
     {
         txtCustomer.Text = Dictionary.CUSTOMER_DELETED_EXCEPTION_MSG;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Save new customer
 /// </summary>
 /// <param name="customer"></param>
 public void SaveNewCustomer(Customer customer)
 {
     var srvDao = NinjectKernelFactory.Kernel.Get<ICustomerDataAccess>();
     using (var tr = TransactionsFactory.CreateTransactionScope())
     {
         try
         {
             srvDao.Save(customer);
         }
         catch (StaleObjectStateException)
         {
             throw new FaultException<ConcurrentUpdateException>(
                 new ConcurrentUpdateException
                 {
                     MessageError = Dictionary.CUSTOMER_CONCURRENT_UPDATE_EXCEPTION_MSG
                 },
                 new FaultReason(Dictionary.CONCURRENT_UPDATE_EXCEPTION_REASON));
         }
         catch (Exception ex)
         {
             throw new FaultException<Exception>(
                 new Exception(ex.Message),
                 new FaultReason(Dictionary.UNKNOWN_REASON));
         }
         tr.Complete();
     }
 }
Ejemplo n.º 4
0
 protected void btnSave_OnClick(object sender, EventArgs e)
 {
     EnableValidator(true);
     Page.Validate();
     if (txtCustomer.Text == Dictionary.COMPANY_ADMIN_NEW_HEADER)
     {
         var customer = new Customer
         {
             FirstName = txtFirstName.Text,
             LastName = txtLastName.Text,
             Sex = DropDownList_Sex.SelectedValue,
             BirthDay = DateTime.ParseExact(txtBirthday.Text, Dictionary.DATE_FORMAT, null),
             Address = txtAddress.Text,
             Email = txtAddress.Text,
             Phone = txtPhone.Text,
             UserName = txtUsername.Text,
             Password = txtPassword.Text
         };
         try
         {
             ClientServiceFactory.CustomerService.SaveNewCustomer(customer);
         }
         catch (FaultException<UserNameAlreadyExistException> ex)
         {
             lblMessage.Text = ex.Detail.MessageError;
         }
         catch (FaultException<Exception> ex)
         {
             lblMessage.Text = ex.Detail.Message;
         }
         RedirectToCustomerAdmin();
     }
     else
     {
         m_customer.FirstName = txtFirstName.Text;
         m_customer.LastName = txtLastName.Text;
         m_customer.Sex = DropDownList_Sex.SelectedValue;
         m_customer.BirthDay = DateTime.ParseExact(txtBirthday.Text, Dictionary.DATE_FORMAT, null);
         m_customer.Address = txtAddress.Text;
         m_customer.Email = txtEmail.Text;
         m_customer.Phone = txtPhone.Text;
         m_customer.UserName = txtUsername.Text;
         m_customer.Password = txtPassword.Text;
         m_customer.RowVersion = s_rowVersion;
         try
         {
             ClientServiceFactory.CustomerService.SaveNewCustomer(m_customer);
         }
         catch (FaultException<ConcurrentUpdateException> ex)
         {
             lblMessage.Text = ex.Detail.MessageError;
         }
         RedirectToCustomerAdmin();
     }
 }