Beispiel #1
0
        /// <summary>
        /// Create a new customer based on the passed in CustomerPost object
        /// </summary>
        /// <param name="customer">A CustomerPost object that represents a customer to be created</param>
        /// <param name="returnUrl">The return url for PayPal transactions</param>
        /// <param name="cancelUrl">The cancel url for PayPal transactions</param>
        /// <returns>A newly created Customer object</returns>
        public async Task <Customer> CreateCustomerWithPayPal(CustomerPost customer, string returnUrl, string cancelUrl)
        {
            Customers customers   = new Customers();
            Customer  newCustomer = new Customer();

            try
            {
                string urlPath    = $"/customers/new/productCode/{_config.productCode}";
                string postParams = "subscription[method]=paypal" +
                                    FormatFunctions.addParam("code", customer.Code) +
                                    FormatFunctions.addParam("firstName", customer.FirstName) +
                                    FormatFunctions.addParam("lastName", customer.LastName) +
                                    FormatFunctions.addParam("email", customer.Email) +
                                    FormatFunctions.addParam("subscription[planCode]", customer.PlanCode) +
                                    FormatFunctions.addParam("subscription[ccFirstName]", customer.CCFirstName) +
                                    FormatFunctions.addParam("subscription[ccLastName]", customer.CCLastName) +
                                    FormatFunctions.addParam("subscription[returnUrl]", returnUrl) +
                                    FormatFunctions.addParam("subscription[cancelUrl]", cancelUrl) +
                                    FormatFunctions.addMetaDataParams(customer.AdditionalMetaData);

                string result = await _httpService.postRequest(urlPath, postParams);

                XDocument newCustomerXML = XDocument.Parse(result);
                customers = getCustomerList(newCustomerXML);
                if (customers.CustomerList.Count > 0)
                {
                    newCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newCustomer);
        }
        public void OpenForm_EditCustomer()
        {
            if (GetTable().SelectedRows.Count <= 0)
            {
                return;
            }
            var customerPost = new CustomerPost();
            var customerId   = Convert.ToInt32(GetTable().CurrentRow.Cells["CustomerTable_ID"].Value);
            Form_editCustomer editCustomer = new Form_editCustomer(customerId);
            var result = editCustomer.ShowDialog();

            if (result == DialogResult.Yes)
            {
                MessageBox.Show("Customer updated successfully !");
                //Refresh Table
                return;
            }
            else if (result == DialogResult.No)
            {
                DialogResult retry = MessageBox.Show("Customer could not be updated. Do you want to try again?", "Failed", MessageBoxButtons.YesNo);
                if (retry == DialogResult.Yes)
                {
                    OpenForm_EditCustomer();
                }
            }
        }
Beispiel #3
0
        public IActionResult Create(CustomerPost model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var customer = customerService.Create(model);

            return(Created($"customer/{customer.Id}", customer));
        }
Beispiel #4
0
        public CustomerGet Create(CustomerPost model)
        {
            var createdCustomer = context.Customers.Add(new Customer
            {
                Name = model.Name,
                Type = model.Type
            });

            context.SaveChanges();

            return(MapEntityToModel(createdCustomer.Entity));
        }
        public async Task <IActionResult> Post(CustomerPost customerPost)
        {
            if (await _customers.ExistsEmail(customerPost.Email))
            {
                throw new Exception("E-mail ja cadastrado");
            }

            var customer = customerPost.CreateDomain();
            await _customers.Insert(customer);

            return(Ok(new Response <long>(customer.Id)));
        }
Beispiel #6
0
        public CustomerGet Post(CustomerPost post)
        {
            var customerDTO = new CustomerDTO(post);

            m_Context.Customers.Add(customerDTO);
            m_Context.SaveChanges();

            if (customerDTO == null)
            {
                return(null);
            }

            return(new CustomerGet(m_Context, customerDTO));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <Empty> Insert(CustomerPost request, ServerCallContext context)
        {
            var customer = new domain.Entities.Customer
            {
                IdAddress = request.IdAddress,
                Name      = request.Name,
                Surname   = request.Surname,
                Cpf       = request.Cpf,
                Genre     = request.Genre.ToCharArray()[0]
            };

            _repositoryCustomer.Insert(customer);

            return(Task.FromResult(new Empty()));
        }
        public void Insert(CustomerDTO customerDTO)
        {
            var proto = _mapperCustomer.DTOToProto(customerDTO);

            var customer = new CustomerPost
            {
                IdAddress = proto.IdAddress,
                Name      = proto.Name,
                Surname   = proto.Surname,
                Cpf       = proto.Cpf,
                Genre     = proto.Genre.ToString()
            };

            _serviceGrpcCustomer.Insert(customer);
        }
        public void UpdateCustomer()
        {
            m_UIControl.lbl_customerErrorText.Text = string.Empty;

            if (!ValidateCustomerDetails())
            {
                return;
            }

            string name         = m_UIControl.tb_customerName.Text.Trim();
            string mobileNumber = m_UIControl.tb_customerMobileNumber.Text.Trim();

            if (CheckIfCustomerNameAlreadyExists(name))
            {
                m_UIControl.lbl_customerErrorText.Text = "Customer with the same Name already exists!";
                return;
            }

            if (CheckIfMobileNumberAlreadyExists(mobileNumber))
            {
                m_UIControl.lbl_customerErrorText.Text = "Customer with the same Mobile Number already exists!";
                return;
            }

            CustomerPost customerPost = new CustomerPost();

            customerPost.ID            = int.Parse(m_UIControl.tb_customerId.Text.Trim());
            customerPost.Name          = name;
            customerPost.MobileNumber  = mobileNumber;
            customerPost.Email         = m_UIControl.tb_customerEmail.Text.Trim();;
            customerPost.TotalAmount   = double.Parse(m_UIControl.tb_customerTotalPurchaseAmount.Text.Trim());
            customerPost.PendingAmount = double.Parse(m_UIControl.tb_customerPendingAmount.Text.Trim());

            m_Customer = DataService.GetCustomerDataController().Put(customerPost);
            if (m_Customer == null)
            {
                m_UIControl.DialogResult = DialogResult.No;
                return;
            }
            m_UIControl.DialogResult = DialogResult.Yes;
            ResetTextBoxes();

            // fire customer updated event
            Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.CUSTOMER, m_Customer.ID);

            EventBroadcaster.Get().BroadcastEvent(e);
        }
Beispiel #10
0
        public CustomerGet Put(CustomerPost post)
        {
            var customerDTO = m_Context.GetCustomer(post.ID);

            if (customerDTO == null)
            {
                return(null);
            }

            customerDTO.CopyFrom(post);

            m_Context.Entry(customerDTO).State = EntityState.Modified;

            m_Context.SaveChanges();

            return(new CustomerGet(m_Context, customerDTO));
        }
Beispiel #11
0
        /// <summary>
        /// Update a customer and their subscription
        /// </summary>
        /// <param name="customer">A CustomerPost object that represents the changes to be updated</param>
        /// <returns>An updated Customer object with the changes applied</returns>
        public async Task <Customer> UpdateCustomerAndSubscription(CustomerPost customer)
        {
            Customers customers       = new Customers();
            Customer  updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlPath    = $"/customers/edit/productCode/{_config.productCode}/code/{customer.Code}";
                string postParams = FormatFunctions.addParam("firstName", customer.FirstName) +
                                    FormatFunctions.addParam("lastName", customer.LastName) +
                                    FormatFunctions.addParam("email", customer.Email) +
                                    FormatFunctions.addParam("company", customer.Company) +
                                    FormatFunctions.addParam("notes", customer.Notes) +
                                    FormatFunctions.addParam("subscription[planCode]", customer.PlanCode.ToString().ToUpper()) +
                                    FormatFunctions.addParam("subscription[ccFirstName]", customer.CCFirstName) +
                                    FormatFunctions.addParam("subscription[ccLastName]", customer.CCLastName) +
                                    FormatFunctions.addParam("subscription[ccNumber]", customer.CCNumber) +
                                    FormatFunctions.addParam("subscription[ccExpiration]", FormatFunctions.formatMonth(customer.CCExpMonth) + @"/" + customer.CCExpYear) +
                                    FormatFunctions.addParam("subscription[ccCardCode]", customer.CCCardCode) +
                                    FormatFunctions.addParam("subscription[ccZip]", customer.CCZip) +
                                    FormatFunctions.addParam("remoteAddress", customer.RemoteAddress) +
                                    FormatFunctions.addMetaDataParams(customer.AdditionalMetaData);

                string result = await _httpService.postRequest(urlPath, postParams);

                XDocument newCustomerXML = XDocument.Parse(result);
                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(updatedCustomer);
        }
Beispiel #12
0
        /// <summary>
        /// Create a new customer based on the passed in CustomerPost object
        /// </summary>
        /// <param name="customer">A CustomerPost object that represents a customer to be created</param>
        /// <returns>A newly created Customer object</returns>
        public async Task <Customer> CreateCustomerWithCreditCard(CustomerPost customer)
        {
            Customers customers   = new Customers();
            Customer  newCustomer = new Customer();

            try
            {
                string urlPath    = $"/customers/new/productCode/{_config.productCode}";
                string postParams = FormatFunctions.addParam("code", customer.Code) +
                                    FormatFunctions.addParam("firstName", customer.FirstName) +
                                    FormatFunctions.addParam("lastName", customer.LastName) +
                                    FormatFunctions.addParam("email", customer.Email) +
                                    FormatFunctions.addParam("company", customer.Company) +
                                    FormatFunctions.addParam("notes", customer.Notes) +
                                    FormatFunctions.addParam("subscription[planCode]", customer.PlanCode) +
                                    FormatFunctions.addParam("subscription[ccFirstName]", customer.CCFirstName) +
                                    FormatFunctions.addParam("subscription[ccLastName]", customer.CCLastName) +
                                    FormatFunctions.addParam("subscription[ccNumber]", customer.CCNumber) +
                                    FormatFunctions.addParam("subscription[ccExpiration]", customer.CCExpiration) +
                                    FormatFunctions.addParam("subscription[ccCardCode]", customer.CCCardCode) +
                                    FormatFunctions.addParam("subscription[ccZip]", customer.CCZip) +
                                    FormatFunctions.addMetaDataParams(customer.AdditionalMetaData);

                string result = await _httpService.postRequest(urlPath, postParams);

                XDocument newCustomerXML = XDocument.Parse(result);
                customers = getCustomerList(newCustomerXML);
                if (customers.CustomerList.Count > 0)
                {
                    newCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newCustomer);
        }
        private void UpdateCustomerDetails()
        {
            //Update customer details
            var customer = m_TransactionSession.GetCustomer();

            if (customer == null || customer.ID == 0)
            {
                return;
            }

            double amountDue  = double.Parse(m_TransactionSession.amountDue);
            double amountPaid = double.Parse(m_TransactionSession.amountPaid);

            CustomerPost customerPost = new CustomerPost();

            customerPost.ID            = customer.ID;
            customerPost.MobileNumber  = customer.MobileNumber;
            customerPost.Name          = customer.Name;
            customerPost.Email         = customer.Email;
            customerPost.TotalAmount   = customer.TotalAmount + amountDue;
            customerPost.PendingAmount = amountDue - amountPaid;
            var c = DataService.GetCustomerDataController().Put(customerPost);
        }
Beispiel #14
0
        public void SaveCustomer()
        {
            m_UIControl.lbl_customerErrorText.Text = string.Empty;
            if (!ValidateCustomerDetails())
            {
                return;
            }

            CustomerPost customerPost = new CustomerPost();

            customerPost.Email         = m_UIControl.tb_customerEmail.Text.Trim();
            customerPost.Name          = m_UIControl.tb_CustomerName.Text.Trim();
            customerPost.MobileNumber  = m_UIControl.tb_customerMobile.Text.Trim();
            customerPost.PendingAmount = 0;
            m_Customer = DataService.GetCustomerDataController().Post(customerPost);

            m_UIControl.DialogResult = (m_Customer == null) ? DialogResult.No : DialogResult.Yes;

            // fire customer added event
            Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.CUSTOMER, m_Customer.ID);

            EventBroadcaster.Get().BroadcastEvent(e);
        }
    /// <summary>
    /// Update a customer and their subscription
    /// </summary>
    /// <param name="customer">A CustomerPost object that represents the changes to be updated</param>
    /// <returns>An updated Customer object with the changes applied</returns>
    public static Customer UpdateCustomerAndSubscription(CustomerPost customer, CGError error)
    {
        Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit/productCode/{0}/code/{1}", _ProductCode, customer.Code);

                if (customer.strPlanCode == null)
                    customer.strPlanCode = customer.PlanCode.ToString().ToUpper();

                string postParams = string.Format(
                    "firstName={0}" +
                    "&lastName={1}" +
                    "&email={2}" +
                    "&company={3}" +
                    "&subscription[planCode]={4}" +
                    "&subscription[ccFirstName]={5}" +
                    "&subscription[ccLastName]={6}" +
                    "&subscription[ccNumber]={7}" +
                    "&subscription[ccExpiration]={8}" +
                    "&subscription[ccCardCode]={9}" +
                    "&subscription[ccZip]={10}" +
                    "&subscription[changeBillDate]={11}",
                    HttpUtility.UrlEncode(customer.FirstName),
                    HttpUtility.UrlEncode(customer.LastName),
                    HttpUtility.UrlEncode(customer.Email),
                    HttpUtility.UrlEncode(customer.Company),
                    HttpUtility.UrlEncode(customer.strPlanCode),
                    HttpUtility.UrlEncode(customer.CCFirstName),
                    HttpUtility.UrlEncode(customer.CCLastName),
                    HttpUtility.UrlEncode(customer.CCNumber),
                    HttpUtility.UrlEncode(customer.CCExpiration),
                    HttpUtility.UrlEncode(customer.CCCardCode),
                    HttpUtility.UrlEncode(customer.CCZip),
                    HttpUtility.UrlEncode(customer.changeBillDate));

                //                    HttpUtility.UrlEncode(string.Format("{0}/{1}", formatMonth(customer.CCExpMonth), customer.CCExpYear)),

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }

            //shyam
            catch (System.Net.WebException ex)
            {
                processWebException(ex, error);
            }
            //shyam

            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
    }
    private void CG_CreateCustomer()
    {
        try
        {
            //Create a new customer
            CustomerPost newCustomer = new CustomerPost();

            newCustomer.Company = CompanyTextBox.Text;
            newCustomer.FirstName = FirstNameTextBox.Text;
            newCustomer.LastName = LastNameTextBox.Text;
            newCustomer.Email = EmailTextBox.Text;

            //Extra fields required for nonFREE plans
            newCustomer.CCFirstName = CCFirstNameTextbox.Text;
            newCustomer.CCLastName = CCLastNameTextBox.Text;
            newCustomer.CCNumber = CCNumberTextBox.Text;
            newCustomer.CCExpiration = CCExpirationTextBox.Text;
            newCustomer.CCZip = CCZipTextBox.Text;
            newCustomer.CCCardCode = CCCardCodeTextBox.Text;

             if (SelectedPlanCode != 0)
             {
                 newCustomer.PlanCode = SelectedPlanCode;
                    newCustomer.Code = AppID;

                    //Send it to the server
                    CGError servererror = new CGError();
                    Customer returnCustomer = CheddarGetter.CreateCustomer(newCustomer, servererror);

                    //FAILURE
                    if (String.IsNullOrEmpty(servererror.Code) == false)
                    {
                        //CG.InnerHtml += "<li>ERROR:" + servererror.Message;
                        RadNotification1.Title = "WARNING";
                        RadNotification1.Text = servererror.Message;
                        RadNotification1.Visible = true;
                        RadNotification1.Show();

                        string clickHandler = "this.disabled = false; this.value=\'Submit\'; ";
                        SubmitButton.Attributes.Add("onclick", clickHandler);

                        return;
                    }

                    //SUCCESS
                    if (String.IsNullOrEmpty(returnCustomer.Code) == false)
                    {
                        AppCGCustomerCode = returnCustomer.Code;

                        CGResponseFlag.Text = AppCGCustomerCode;

                        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

                        //If the App was submitted to a store [native & hybrid] then just update the paid_services table entry with status to paid.
                        //If not [web apps] create a new entry in paid_services and update status to paid.
                        String app_name = State["SelectedApp"].ToString();
                        BillingUtil billingutil = new BillingUtil();
                        if (billingutil.IsAppStoreSubmissionPaid(State, app_name))
                        {
                            string confirm = returnCustomer.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();

                            string sku = returnCustomer.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();

                            billingutil.UpdatePaidServicesDB(confirm,sku, State);
                        }
                        else
                        {
                            string confirm = returnCustomer.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();
                            string sku = returnCustomer.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();
                            billingutil.StorePaidServicesDB(confirm, sku, State, true);
                        }

                    }
                }

        }//end try
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            throw;
        }
    }
    private Boolean CG_ModifyCustomer()
    {
        try
        {
            //Create a new customer
            CustomerPost newCustomer = new CustomerPost();

            newCustomer.Company = CompanyTextBox.Text;
            newCustomer.FirstName = FirstNameTextBox.Text;
            newCustomer.LastName = LastNameTextBox.Text;
            newCustomer.Email = EmailTextBox.Text;

            //Extra fields required for nonFREE plans
            newCustomer.CCFirstName = CCFirstNameTextbox.Text;
            newCustomer.CCLastName = CCLastNameTextBox.Text;
            newCustomer.CCNumber = CCNumberTextBox.Text;
            newCustomer.CCExpiration = CCExpirationTextBox.Text;
            newCustomer.CCZip = CCZipTextBox.Text;
            newCustomer.CCCardCode = CCCardCodeTextBox.Text;

            if (SelectedPlanCode != 0)
            {
                    newCustomer.PlanCode = SelectedPlanCode;                 //The updated plan code goes here
                    newCustomer.Code = AppID;                           //existing customer code
                    System.Diagnostics.Debug.WriteLine("using customer code" + newCustomer.Code + "To modifyplan to " + newCustomer.PlanCode);

                    //Send it to the server
                    CGError servererror = new CGError();
                    Customer returnCustomer = CheddarGetter.UpdateCustomerAndSubscription(newCustomer, servererror);

                    //FAILURE
                    if (String.IsNullOrEmpty(servererror.Code) == false)
                    {
                        //CG.InnerHtml += "<li>ERROR:" + servererror.Message;
                        RadNotification1.Title = "WARNING";
                        RadNotification1.Text = servererror.Message;
                        RadNotification1.Visible = true;
                        RadNotification1.Show();
                        return false;
                    }

                    //SUCCESS
                    if (String.IsNullOrEmpty(returnCustomer.Code) == false)
                    {
                        AppCGCustomerCode = returnCustomer.Code;
                        CGResponseFlag.Text = AppCGCustomerCode;

                        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
                        BillingUtil billingutil = new BillingUtil();
                        string confirm = returnCustomer.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();

                        string sku = returnCustomer.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();

                        billingutil.UpdatePaidServicesDB(confirm,sku,State);
                    }
                }

            return true;

        }//end try
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            throw;
        }
    }
        public ActionResult PostCustomer(CustomerPost post, HttpPostedFileBase fileUpload)
        {
            ViewBag.RealEstaleType = new SelectList(db.RealEstateTypes.ToList().OrderBy(n => n.Name), "RealEstateType_ID", "Name");
            ViewBag.PostType       = new SelectList(db.Type1.ToList().OrderBy(n => n.Name), "PostType_ID", "Name");
            ViewBag.Direction      = new SelectList(db.Directions.ToList().OrderBy(n => n.Direction_Name), "Direction_ID", "Direction_Name");
            if (Session["Account"] == null || Session["Account"].ToString() == "")
            {
                return(RedirectToAction("Login", "Account"));
            }
            if (ModelState.IsValid)
            {
                Account cst     = Session["Account"] as Account;
                var     account = db.Accounts.Where(x => x.Account_ID == cst.Account_ID);
                Project project = new Project();
                project.ProjectName = post.ProjectName;
                project.Location    = post.LocationProject;
                project.Protential  = post.Protential;

                Detail pst_detail = new Detail();
                pst_detail.Floor     = post.Floor;
                pst_detail.Bedroom   = post.Bedroom;
                pst_detail.Bathroom  = post.Bathroom;
                pst_detail.Direction = db.Directions.Find(post.Direction);

                Post pst  = new Post();
                var  cust = db.Customers.Where(x => x.Account.Account_ID == cst.Account_ID).FirstOrDefault();
                pst.Customer       = cust;
                pst.Tittle         = post.Tittle;
                pst.Price          = post.Price;
                pst.Location       = post.Location;
                pst.Area           = post.Area;
                pst.Description    = post.Description;
                pst.RealEstateType = db.RealEstateTypes.Find(post.RealEstaleType);
                pst.Type1          = db.Type1.Find(post.PostType);
                Post_Image pst_img = new Post_Image();
                pst.Project = project;
                pst.Detail  = pst_detail;
                //Lưu tên file
                var fileName = Path.GetFileName(fileUpload.FileName);
                //Lưu đường dẫn của file
                var path = Path.Combine(Server.MapPath("~/Images/Post"), fileName);
                if (System.IO.File.Exists(path))
                {
                    ViewBag.ThongBao = "Images already exists";
                }
                else
                {
                    fileUpload.SaveAs(path);
                }
                pst_img.url = fileUpload.FileName;

                Project_Image pr_img    = new Project_Image();
                var           fileName1 = Path.GetFileName(fileUpload.FileName);
                var           path1     = Path.Combine(Server.MapPath("~/Images/Project"), fileName1);
                if (System.IO.File.Exists(path1))
                {
                    ViewBag.ThongBao = "Images already exists";
                }
                else
                {
                    fileUpload.SaveAs(path1);
                }
                pr_img.url = fileUpload.FileName;

                db.Projects.Add(project);
                db.Posts.Add(pst);
                pst.Post_Image.Add(pst_img);
                project.Project_Image.Add(pr_img);
                db.Details.Add(pst_detail);
                db.SaveChanges();
                ViewBag.ThongBao1 = "Post successful";
            }
            return(View());
        }
    private bool UpdateCheddarGetterPerApp(string AppID)
    {
        try
        {
            CGError servererror = new CGError();
            Customer customer_details = CheddarGetter.GetCustomer(AppID, servererror);

            if (String.IsNullOrEmpty(servererror.Code) == false)
            {
                RadNotification1.Title = "WARNING";
                RadNotification1.Text = servererror.Message + " . Please contact [email protected] for assistance";
                RadNotification1.Visible = true;
                RadNotification1.Show();
                return false;
            }

            CustomerPost updateCustomer = new CustomerPost();

            //Copy over the plan since we are not changing that.
            updateCustomer.strPlanCode = customer_details.Subscriptions[0].SubscriptionsPlans[0].Code;

            updateCustomer.Company = CompanyTextBox.Text;
            updateCustomer.FirstName = FirstNameTextBox.Text;
            updateCustomer.LastName = LastNameTextBox.Text;
            updateCustomer.Email = EmailTextBox.Text;

            //Extra fields required for nonFREE plans
            updateCustomer.CCFirstName = CCFirstNameTextbox.Text;
            updateCustomer.CCLastName = CCLastNameTextBox.Text;
            updateCustomer.CCNumber = CCNumberTextBox.Text;
            updateCustomer.CCExpiration = CCExpirationTextBox.Text;
            updateCustomer.CCZip = CCZipTextBox.Text;
            updateCustomer.CCCardCode = CCCardCodeTextBox.Text;

            updateCustomer.Code = AppID;
            System.Diagnostics.Debug.WriteLine("Updating Customerinfo for AppID=" + AppID);

            //Send it to the server
            Customer returnCustomer = CheddarGetter.UpdateCustomerAndSubscription(updateCustomer, servererror);
            //FAILURE
            if (String.IsNullOrEmpty(servererror.Code) == false)
            {
                RadNotification1.Title = "WARNING";
                RadNotification1.Text = servererror.Message + " . Please contact [email protected] for assistance";
                RadNotification1.Visible = true;
                RadNotification1.Show();
                return false;
            }

            //SUCCESS
            if (String.IsNullOrEmpty(returnCustomer.Code) == false)
                return true;

        }

        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            throw;
        }
        return false;
    }
    /// <summary>
    /// Update a customer
    /// </summary>
    /// <param name="customer">A CustomerPost object that represents the changes to be updated</param>
    /// <returns>An updated Customer object with the changes applied</returns>
    public static Customer UpdateCustomer(CustomerPost customer)
    {
        Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit-customer/productCode/{0}/code/{1}", _ProductCode, customer.Code);

                string postParams = string.Format(
                    "firstName={0}" +
                    "&lastName={1}" +
                    "&email={2}" +
                    "&company={3}",
                    HttpUtility.UrlEncode(customer.FirstName),
                    HttpUtility.UrlEncode(customer.LastName),
                    HttpUtility.UrlEncode(customer.Email),
                    HttpUtility.UrlEncode(customer.Company));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
    }
    private Boolean CG_CreateFreeCustomerAndInvoices()
    {
        try
        {
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

            //Create a new customer
            CustomerPost newCustomer = new CustomerPost();

            newCustomer.Company = CompanyTextBox.Text;
            newCustomer.FirstName = FirstNameTextBox.Text;
            newCustomer.LastName = LastNameTextBox.Text;
            newCustomer.Email = EmailTextBox.Text;
            newCustomer.CCFirstName = CCFirstNameTextbox.Text;
            newCustomer.CCLastName = CCLastNameTextBox.Text;
            newCustomer.CCNumber = CCNumberTextBox.Text;
            newCustomer.CCExpiration = CCExpirationTextBox.Text;
            newCustomer.CCZip = CCZipTextBox.Text;
            newCustomer.CCCardCode = CCCardCodeTextBox.Text;
            newCustomer.Code = State["application_id"].ToString();

           //For Branding purposes create appropriate branding code.
            if (State["SelectedDeviceType"].ToString() == Constants.ANDROID_PHONE)
            {
                newCustomer.PlanCode =  PlanCodeEnum.ANDROID_BRANDING;
            }
            else
            {
                if (State["SelectedDeviceType"].ToString() == Constants.IPHONE)
                {
                    newCustomer.PlanCode = PlanCodeEnum.IOS_BRANDING;
                }
                else
                {
                    RadNotification1.Title = "WARNING";
                    RadNotification1.Text = "This application has no device type.";
                    RadNotification1.Visible = true;
                    RadNotification1.Show();
                    return false;
                }
            }

            //Send it to the server
            CGError servererror = new CGError();
            Customer returnCustomer = CheddarGetter.CreateCustomer(newCustomer, servererror);

            //FAILURE
            if (String.IsNullOrEmpty(servererror.Code) == false)
            {

                //string clickHandler = "this.disabled = false; this.value=\'Submit\'; ";
                // SubmitButton.Attributes.Add("onclick", clickHandler);

                SubmitButton.Enabled = true;
                SubmitButton.Text = "Submit";

                //CG.InnerHtml += "<li>ERROR:" + servererror.Message;
                RadNotification1.Title = "WARNING";
                RadNotification1.Text = servererror.Message;
                RadNotification1.Visible = true;
                RadNotification1.Show();

                return false;
            }

            //SUCCESS
            if (String.IsNullOrEmpty(returnCustomer.Code) == false)
            {
                AppCGCustomerCode = returnCustomer.Code;
            }

            // IF SUCCESSFULLY ABLE TO CREATE THE FREE NATIVE CUSTOMER THEN KICK OFF A ONE TIME INVOICE FOR BRANDING

            OneTimeInvoicePost myonetimeinvoice = new OneTimeInvoicePost();

            myonetimeinvoice.InvoiceCharges = new CustomChargePost[1];

            int number_of_charges = 0;
            CustomChargePost mycustom1 = new CustomChargePost();

            mycustom1.CustomerCode = AppCGCustomerCode;
            mycustom1.Description = "Branding";
            mycustom1.ChargeCode = "BRANDING ";
            mycustom1.EachAmount = 0;
            mycustom1.Quantity = 0;

            if ((State["SelectedDeviceType"].ToString() == Constants.ANDROID_PHONE || State["SelectedDeviceType"].ToString() == Constants.ANDROID_TABLET) && (String.IsNullOrEmpty(AppCGCustomerCode) == false))
            {
                mycustom1.ChargeCode += "- ANRDOID";
                mycustom1.CustomerCode = AppCGCustomerCode;
                mycustom1.Quantity = 1;
                mycustom1.EachAmount += 99;
                mycustom1.Description += "- Android";
            }

            if ((State["SelectedDeviceType"].ToString() == Constants.IPHONE || State["SelectedDeviceType"].ToString() == Constants.IPAD) && (String.IsNullOrEmpty(AppCGCustomerCode) == false))
            {
                mycustom1.ChargeCode += "- iOS";
                mycustom1.Quantity = 1;
                mycustom1.EachAmount += 99;
                mycustom1.Description += "- iOS";
            }

            myonetimeinvoice.InvoiceCharges[number_of_charges] = new CustomChargePost();
            myonetimeinvoice.InvoiceCharges[number_of_charges] = mycustom1;

            CGError servererror2 = new CGError();
            //SERVER CALL TO THE ONE TIME INVOICE for both charges at once.
            Customer returnCustomer2 = CheddarGetter.CreateOneTimeInvoice(myonetimeinvoice, servererror2);

            if (String.IsNullOrEmpty(servererror2.Code) == false)
            {
                //CG.InnerHtml += "<li>ERROR:" + servererror2.Message;

                SubmitButton.Enabled = true;
                SubmitButton.Text = "Submit";

                //string clickHandler = "this.disabled = false; this.value=\'Submit\'; ";
                //SubmitButton.Attributes.Add("onclick", clickHandler);

                RadNotification1.Title = "WARNING";
                RadNotification1.Text = servererror2.Message;
                RadNotification1.Visible = true;
                RadNotification1.Show();

                return false;
            }

            //Store in the PaidServicesDB
            BillingUtil billingutil = new BillingUtil();

            //Record the new SKU but do not turn on the 'paid' field as yet.

            string confirm = returnCustomer2.Subscriptions[0].Invoices[1].PaidTransactionId.ToString();

            string sku = returnCustomer2.Subscriptions[0].SubscriptionsPlans[0].Code.ToString();
            billingutil.StorePaidServicesDB(confirm,sku,State,false);

            //Enable 10 day grace for App store Approval.
            Util util = new Util();
            util.SetFreeProductionExpiration(State, DateTime.Now.ToUniversalTime().AddDays(10.0D));

            //Send Email to Support.
            System.Text.StringBuilder body = new System.Text.StringBuilder("Customer Username: "******"Username"].ToString() + "\n");
            body.Append("App Name: " + State["SelectedApp"].ToString() + "\n");
            body.Append("\n-- ViziApps Support");
            Email email = new Email();
            string status = email.SendEmail(State,  HttpRuntime.Cache["TechSupportEmail"].ToString(),  HttpRuntime.Cache["TechSupportEmail"].ToString(),"", "", "Customer submitted App for App Store Preparation", body.ToString(), "", false);

            return true;

        }//end try

        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString() + ex.StackTrace.ToString());

        }

        return false;
    }
    /// <summary>
    /// Update a customer's subscription with only partial subscription information
    /// </summary>
    /// <param name="customer">A CustomerPost object with the changes that are to be updated</param>
    /// <returns>A Customer object with the applied changes</returns>
    public static Customer UpdateSubscriptionPartial(CustomerPost customer)
    {
        Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit-subscription/productCode/{0}/code/{1}", _ProductCode, customer.Code);

                //note: expiration date must be in MM/YYYY format
                string postParams = string.Format(
                    "planCode={0}" +
                    "&ccFirstName={1}" +
                    "&ccLastName={2}" +
                    "&ccZip={3}",
                    HttpUtility.UrlEncode(customer.PlanCode.ToString().ToUpper()),
                    HttpUtility.UrlEncode(customer.CCFirstName),
                    HttpUtility.UrlEncode(customer.CCLastName),
                    HttpUtility.UrlEncode(customer.CCZip));

                string result = postRequest(urlBase, urlPath, postParams);
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
    }
    /// <summary>
    /// Update a customer's subscription
    /// </summary>
    /// <param name="customer">A CustomerPost object with the subscription details to update</param>
    /// <returns>A Customer object with the applied changes</returns>
    public static Customer UpdateSubscription(CustomerPost customer, CGError error)
    {
        Customers customers = new Customers();
            Customer updatedCustomer = new Customer();

            try
            {
                // Create the web request
                string urlBase = "https://cheddargetter.com/xml";
                string urlPath = string.Format("/customers/edit-subscription/productCode/{0}/code/{1}", _ProductCode, customer.Code);

                //note: expiration date must be in MM/YYYY format
                StringBuilder postParamsSB = new StringBuilder();
                postParamsSB.Append(string.Format("planCode={0}", HttpUtility.UrlEncode(customer.PlanCode.ToString().ToUpper())));
                postParamsSB.Append(string.Format("&ccFirstName={0}", HttpUtility.UrlEncode(customer.CCFirstName)));
                postParamsSB.Append(string.Format("&ccLastName={0}", HttpUtility.UrlEncode(customer.CCLastName)));

                if (!string.IsNullOrEmpty(customer.CCNumber))
                {
                    postParamsSB.Append(string.Format("&ccNumber={0}", HttpUtility.UrlEncode(customer.CCNumber)));
                }

                //postParamsSB.Append(string.Format("&ccExpiration={0}", HttpUtility.UrlEncode(string.Format("{0}/{1}", formatMonth(customer.CCExpMonth), customer.CCExpYear))));
                postParamsSB.Append(string.Format("&ccExpiration={0}", HttpUtility.UrlEncode(customer.CCExpiration)));
                if (!string.IsNullOrEmpty(customer.CCCardCode))
                {
                    postParamsSB.Append(string.Format("&ccCardCode={0}", HttpUtility.UrlEncode(customer.CCCardCode)));
                }

                postParamsSB.Append(string.Format("&ccZip={0}", HttpUtility.UrlEncode(customer.CCZip)));

                string result = postRequest(urlBase, urlPath, postParamsSB.ToString());
                XDocument newCustomerXML = XDocument.Parse(result);

                customers = getCustomerList(newCustomerXML);

                if (customers.CustomerList.Count > 0)
                {
                    updatedCustomer = customers.CustomerList[0];
                }
            }

            //shyam
            catch (System.Net.WebException ex)
            {
                processWebException(ex, error);
            }
            //shyam

            catch (Exception ex)
            {
                throw ex;
            }

            return updatedCustomer;
    }