public void Add(CustomerDomainModel customerDomainModel)
        {
            var customerDataModel = new CustomerDataModel()
            {
                Id       = customerDomainModel.Id,
                AgentId  = customerDomainModel.AgentId,
                Guid     = customerDomainModel.Guid,
                IsActive = customerDomainModel.IsActive,
                Balance  = customerDomainModel.Balance,
                Age      = customerDomainModel.Age,
                EyeColor = customerDomainModel.EyeColor,
                Name     = new CustomerDataModel.CustomerName()
                {
                    First = customerDomainModel.Name.First,
                    Last  = customerDomainModel.Name.Last
                },
                Company    = customerDomainModel.Company,
                Email      = customerDomainModel.Email,
                Phone      = customerDomainModel.Phone,
                Address    = customerDomainModel.Address,
                Registered = customerDomainModel.Registered,
                Latitude   = customerDomainModel.Latitude,
                Longitude  = customerDomainModel.Longitude,
                Tags       = customerDomainModel.Tags
            };

            _customerRepository.Add(customerDataModel);
        }
        public async Task <IActionResult> DeleteCustomer([FromBody] CustomerDataModel customerDataModel)
        {
            try
            {
                if (customerDataModel != null)
                {
                    //delete Customer Listing Favorites Mapping
                    //delete Customer Listing Recommendations
                    //delete Customer MediaFileMapping
                    //delete Customer Store Favorites Mapping
                    //delete Measurements Profile

                    var customerDeleted = await CustomerHandler.DeleteCustomer(customerDataModel.Customer);

                    if (customerDeleted == false)
                    {
                        return(StatusCode(505, "An unexpected error has ocurred, unable to delete Customer"));
                    }
                    Logger.LogWarning("Customer deleted");
                    return(Ok(customerDeleted));
                }
                return(StatusCode(404));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                return(StatusCode(505, ex.Message));
            }
        }
Exemple #3
0
        public static async Task <Customer> UpdateCustomer(CustomerDataModel cdm)
        {
            if (cdm.Customer != null)
            {
                Customer c = cdm.Customer;

                using (var conn = Business.Database.Connection)
                {
                    var newCustomer = await conn.QueryAsync <Customer>("CustomerUpdate", new
                    {
                        c.CustomerId,
                        c.MeasurementsId,
                        c.Email,
                        c.Active,
                        c.Username,
                        c.FirstName,
                        c.LastName,
                        c.Birthdate,
                        c.Gender,
                        c.TimeZoneId,
                        c.InstagramHandle,
                        c.StripeUserID
                    },
                                                                       commandType : CommandType.StoredProcedure);

                    if (newCustomer.Count() > 0)
                    {
                        return(newCustomer.AsList()[0]);
                    }
                    return(null);
                }
            }
            return(null);
        }
        public IHttpActionResult Get(int id, bool official)
        {
            var contest = this.Data.CustomerCards.GetById(id);
            ValidateContest(contest, official);

            var participantFound = this.Data.Customers.Any(id, UserProfile.Id, official);

            if (!participantFound)
            {
                if (!contest.ShouldShowRegistrationForm(official))
                {
                    this.Data.Customers.Add(new Customer(id, this.UserProfile.Id, official));
                    this.Data.SaveChanges();
                }
                else
                {
                    // Participant not found, the contest requires password or the contest has questions
                    // to be answered before registration. Redirect to the registration page.
                    // The registration page will take care of all security checks.
                    return this.Register(id, official);
                }
            }

            var participant = this.Data.Customers.GetWithContest(id, this.UserProfile.Id, official);
            var participantViewModel = new CustomerDataModel(participant, official);

            return this.Ok(participantViewModel);
        }
        public string MailMerge([FromBody] ExportData exportData)
        {
            Byte[]       data   = Convert.FromBase64String(exportData.documentData.Split(',')[1]);
            MemoryStream stream = new MemoryStream();

            stream.Write(data, 0, data.Length);
            stream.Position = 0;
            try
            {
                Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx);
                document.MailMerge.RemoveEmptyGroup      = true;
                document.MailMerge.RemoveEmptyParagraphs = true;
                document.MailMerge.ClearFields           = true;
                document.MailMerge.Execute(CustomerDataModel.GetAllRecords());
                document.Save(stream, Syncfusion.DocIO.FormatType.Docx);
            }
            catch (Exception)
            { }
            string sfdtText = "";

            Syncfusion.EJ2.DocumentEditor.WordDocument worddocument = Syncfusion.EJ2.DocumentEditor.WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);
            sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(worddocument);
            worddocument.Dispose();
            return(sfdtText);
        }
Exemple #6
0
        public override Task <CustomerDataModel> GetCustomerInfo(CustomerFindModel request, ServerCallContext context)
        {
            var model = new CustomerDataModel();

            if (request.UserId == 1)
            {
                model.FirstName = "Ivan";
                model.LastName  = "Zhang";
            }
            else if (request.UserId == 2)
            {
                model.FirstName = "Eva";
                model.LastName  = "Zhang";
            }
            else if (request.UserId == 3)
            {
                model.FirstName = "Guopin";
                model.LastName  = "Zhao";
            }
            else
            {
                model.FirstName = "Yina";
                model.LastName  = "Zhang";
            }

            return(Task.FromResult(model));
        }
Exemple #7
0
        public bool CreateNewCustomer(CustomerDataModel customer)
        {
            bool isSuccess = false;

            Initialize();

            using (SqlConn)
            {
                SqlConn.Open();
                using (SqlCommand sqlCommand = new SqlCommand())
                {
                    sqlCommand.Connection  = SqlConn;
                    sqlCommand.CommandText = insertNewCustomer;

                    sqlCommand.Parameters.AddWithValue("@val1", customer.FirstName);
                    sqlCommand.Parameters.AddWithValue("@val2", customer.LastName);
                    sqlCommand.Parameters.AddWithValue("@val3", customer.Address);
                    sqlCommand.Parameters.AddWithValue("@val4", customer.ContactNumber);

                    try
                    {
                        sqlCommand.ExecuteNonQuery();
                        isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        isSuccess = false;
                    }
                }
            }

            return(isSuccess);
        }
        public CustomerDataModel GetCustomerByIdentifier(int customerId)
        {
            string sql = "select customer_id, customer_name, customer_phone, customer_email from customers where customer_id = @customer_id";

            CustomerDataModel result = _dbConnection.Query <CustomerDataModel>(sql, new { customer_id = customerId }).FirstOrDefault();

            return(result);
        }
Exemple #9
0
 public static CustomerDataModel GetSingleData(string sql)
 {
     using (IDbConnection cnn = new SqlConnection(Startup.DevConnectionString))
     {
         CustomerDataModel data = cnn.QuerySingle <CustomerDataModel>(sql);
         return(data);
     }
 }
        public int InsertNewCustomer(CustomerDataModel dataModel)
        {
            string sql = "INSERT INTO CUSTOMERS(customer_name, customer_phone, customer_email) values (@CUSTOMER_NAME, @CUSTOMER_PHONE, @CUSTOMER_EMAIL); select last_insert_id();";

            int result = _dbConnection.Query <int>(sql, dataModel).FirstOrDefault();

            return(result);
        }
Exemple #11
0
        public static CustomerDataModel GetCustomer(int ID)
        {
            string sql = @"select ID, FirstName, LastName, Occupation, City, State, Email, ImageURL 
                            from dbo.Customers where ID = " + ID.ToString();

            CustomerDataModel data = SQLDataAccess.GetSingleData(sql);

            return(data);
        }
        public IActionResult ViewDetails()
        {
            CustomerDataModel cd = new CustomerDataModel();

            cd.Name      = "Steven Clark";
            cd.Age       = 34;
            ViewBag.Name = cd.Name;
            ViewBag.Age  = Convert.ToString(cd.Age);
            return(View("Index"));
        }
        public ActionResult Create()
        {
            CustomerDataModel customer = new CustomerDataModel();

            ViewData["Message"] = new Faker().Lorem.Paragraph().ToString();
            customer.customerId = GeneratePersonId();

            //pass value from model into the view
            return(View(customer));
        }
        public void Patch(int id, JsonPatchDocument <CustomerDomainModel> customerDomainModel)
        {
            var customerToPatchDataModel   = _customerRepository.FindById(id);
            var customerToPatchDomainModel = new CustomerDomainModel();

            customerToPatchDomainModel.Id       = customerToPatchDataModel.Id;
            customerToPatchDomainModel.AgentId  = customerToPatchDataModel.AgentId;
            customerToPatchDomainModel.Guid     = customerToPatchDataModel.Guid;
            customerToPatchDomainModel.IsActive = customerToPatchDataModel.IsActive;
            customerToPatchDomainModel.Balance  = customerToPatchDataModel.Balance;
            customerToPatchDomainModel.Age      = customerToPatchDataModel.Age;
            customerToPatchDomainModel.EyeColor = customerToPatchDataModel.EyeColor;
            customerToPatchDomainModel.Name     = new CustomerDomainModel.CustomerName()
            {
                First = customerToPatchDataModel.Name.First,
                Last  = customerToPatchDataModel.Name.Last
            };
            customerToPatchDomainModel.Company    = customerToPatchDataModel.Company;
            customerToPatchDomainModel.Email      = customerToPatchDataModel.Email;
            customerToPatchDomainModel.Phone      = customerToPatchDataModel.Phone;
            customerToPatchDomainModel.Address    = customerToPatchDataModel.Address;
            customerToPatchDomainModel.Registered = customerToPatchDataModel.Registered;
            customerToPatchDomainModel.Latitude   = customerToPatchDataModel.Latitude;
            customerToPatchDomainModel.Longitude  = customerToPatchDataModel.Longitude;
            customerToPatchDomainModel.Tags       = customerToPatchDataModel.Tags;

            customerDomainModel.ApplyTo(customerToPatchDomainModel);

            var patchedCustomerDataModel = new CustomerDataModel()
            {
                Id       = customerToPatchDomainModel.Id,
                AgentId  = customerToPatchDomainModel.AgentId,
                Guid     = customerToPatchDomainModel.Guid,
                IsActive = customerToPatchDomainModel.IsActive,
                Balance  = customerToPatchDomainModel.Balance,
                Age      = customerToPatchDomainModel.Age,
                EyeColor = customerToPatchDomainModel.EyeColor,
                Name     = new CustomerDataModel.CustomerName()
                {
                    First = customerToPatchDomainModel.Name.First,
                    Last  = customerToPatchDomainModel.Name.Last
                },
                Company    = customerToPatchDomainModel.Company,
                Email      = customerToPatchDomainModel.Email,
                Phone      = customerToPatchDomainModel.Phone,
                Address    = customerToPatchDomainModel.Address,
                Registered = customerToPatchDomainModel.Registered,
                Latitude   = customerToPatchDomainModel.Latitude,
                Longitude  = customerToPatchDomainModel.Longitude,
                Tags       = customerToPatchDomainModel.Tags
            };

            _customerRepository.Update(patchedCustomerDataModel);
        }
Exemple #15
0
        public ActionResult DoUpdate(CustomerDataModel customerObj)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(ConfigurationManager.AppSettings["CustomerServiceURL"].ToString());
            string ApiKey = Crypto.Decrypt(Request.Cookies["Adminid"].Value);

            var response = JsonConvert.DeserializeObject <Result>(client.PostAsJsonAsync("update/" + ApiKey, customerObj).Result.Content.ReadAsStringAsync().Result);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemple #16
0
        private CustomerDataModel GetCustomer()
        {
            customer = new CustomerDataModel()
            {
                FirstName     = txtFirstName.Text,
                LastName      = txtLastName.Text,
                Address       = txtAddress.Text,
                ContactNumber = txtContactNumber.Text
            };

            return(customer);
        }
        public ActionResult SignUp(int ID)
        {
            if (ID != 0)
            {
                CustomerDataModel customer = DataLogic.GetCustomer(ID);
                ViewBag.Message = "Update Customer";
                return(View(customer));
            }

            ViewBag.Message = "Add New Customer";

            return(View());
        }
        public int AddNewCustomer(CustomerRequest aNewCustomer)
        {
            CustomerDataModel dataModel = new CustomerDataModel()
            {
                CUSTOMER_NAME  = aNewCustomer.Name,
                CUSTOMER_EMAIL = aNewCustomer.Email,
                CUSTOMER_PHONE = aNewCustomer.Phone
            };

            int Identifier = _libraryQuery.InsertNewCustomer(dataModel);

            return(Identifier);
        }
Exemple #19
0
 // Mapping function for multiple table queries.
 private static CustomerDataModel MapResults(CustomerDataModel customer, FinancialDataModel financial)
 {
     if (financial != null)
     {
         customer.FinancialData = financial;
         return(customer);
     }
     else
     {
         FinancialDataModel generateModel = new FinancialDataModel();
         customer.FinancialData = generateModel;
         return(customer);
     }
 }
        public Customer Add(Customer customer)
        {
            CustomerDataModel model = new CustomerDataModel()
            {
                Email = customer.Email,
                Name  = customer.Name
            };

            _context.Customers.Add(model);
            _context.SaveChanges();

            customer.Id = model.Id;

            return(customer);
        }
Exemple #21
0
        public ActionResult SaveCustomerForm(CustomerDataModel objCustomerData)
        {
            string errorMessage = string.Empty;

            try
            {
                int FactoryId    = SessionManagement.FactoryID;
                var CustomerData = objCustomerData;

                using (ISEEEntities context = new ISEEEntities())
                {
                    Customer customer = new Customer();
                    customer.CreateDate     = DateTime.Now;
                    customer.BuildingCode   = objCustomerData.BuldingCode;
                    customer.CustomerNumber = objCustomerData.CustomerNumber;
                    customer.Factory        = FactoryId;
                    customer.FirstName      = objCustomerData.CompanyName;
                    customer.LastName       = objCustomerData.ContactName;
                    customer.Floor          = objCustomerData.Floor;
                    customer.Apartment      = objCustomerData.Apartment;
                    customer.AreaPhone1     = objCustomerData.PhoneArea1;
                    customer.Phone1         = objCustomerData.Phone1;
                    customer.AreaPhone2     = objCustomerData.PhoneArea2;
                    customer.Phone2         = objCustomerData.Phone2;
                    customer.AreaFax        = objCustomerData.AreaFax;
                    customer.Fax            = objCustomerData.Fax;
                    customer.Mail           = objCustomerData.Mail;
                    customer.VisitInterval  = objCustomerData.VisitInterval;
                    customer.NextVisit      = objCustomerData.NextVisit;
                    customer.VisitTime      = objCustomerData.VisitTime;
                    context.Customers.Add(customer);
                    context.SaveChanges();
                    var customerDetails = new { CustomerID = customer.CustomerId, LastName = customer.LastName, FirstName = customer.FirstName, AreaPhone1 = customer.AreaPhone1, Phone1 = customer.Phone1 };
                    return(new JsonResult {
                        Data = new { Message = "Success", CustomerDetails = customerDetails }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.InnerException.Message;
            }
            return(new JsonResult {
                Data = new { Message = "Error", ErrorDetails = errorMessage }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemple #22
0
        public Customer(bool isAdd, int customerId)
        {
            InitializeComponent();
            this.isAdd = isAdd;

            if (!isAdd)
            {
                Text     = "Edit Customer ~~";
                customer = SQLCustomer.Instance.GetCustomerData(customerId);

                if (customer != null)
                {
                    txtFirstName.Text     = customer.FirstName;
                    txtLastName.Text      = customer.LastName;
                    txtContactNumber.Text = customer.ContactNumber;
                    txtAddress.Text       = customer.Address;
                }
            }
        }
Exemple #23
0
        public static int CreateCustomer(string firstName, string lastName, string occupation,
                                         string city, string state, string email, string imageURL)
        {
            CustomerDataModel data = new CustomerDataModel
            {
                FirstName  = firstName,
                LastName   = lastName,
                Occupation = occupation,
                City       = city,
                State      = state,
                Email      = email,
                ImageURL   = imageURL
            };

            string sql = @"insert into dbo.Customers (FirstName, LastName, Occupation, City, State, Email, ImageURL)
                            values (@FirstName, @LastName, @Occupation, @City, @State, @Email, @ImageURL);";

            return(SQLDataAccess.SaveData(sql, data));
        }
Exemple #24
0
        public static int UpdateCustomer(string inID, string firstName, string lastName, string occupation,
                                         string city, string state, string email, string imageURL)
        {
            CustomerDataModel data = new CustomerDataModel
            {
                FirstName  = firstName,
                LastName   = lastName,
                Occupation = occupation,
                City       = city,
                State      = state,
                Email      = email,
                ImageURL   = imageURL
            };

            string sql = @"Update dbo.Customers SET FirstName = @firstName, LastName = @lastName, Occupation = @occupation,
                           City = @city, State = @state, Email = @email, ImageURL = @imageURL WHERE ID = " + inID;

            return(SQLDataAccess.UpdateData(sql, data));
        }
Exemple #25
0
        //UPDATE a record from the DB
        public static int UpdateCustomer(int id, string firstName, string lastName,
                                         string address, string city, string province, string postalCode, string phoneNumber, string email, string leadSource, string status,
                                         string notes)
        {
            var parameter = new DynamicParameters();

            parameter.Add("CustomerID", id);

            CustomerDataModel data = new CustomerDataModel
            {
                CustomerID  = id,
                FirstName   = firstName,
                LastName    = lastName,
                Address     = address,
                City        = city,
                Province    = province,
                PostalCode  = postalCode,
                PhoneNumber = phoneNumber,
                Email       = email,
                LeadSource  = leadSource,
                Status      = status,
                Notes       = notes
            };

            string sql = @"UPDATE Customer
                           SET 
                           FirstName = @FirstName,
                           LastName = @LastName,
                           Address = @Address,
                           City = @City,
                           Province = @Province,
                           PostalCode = @PostalCode,
                           PhoneNumber = @PhoneNumber,
                           Email = @Email,
                           LeadSource = @LeadSource,
                           Status = @Status,
                           Notes = @Notes
                           WHERE CustomerID = @CustomerID";

            return(SqlDataAccess.SaveData(sql, data));
        }
        public AddCustomers(CustomerDataModel customer)
        {
            InitializeComponent();

            nametextBox.Text            = customer.customerName;
            phoneMaskedTextBox.Text     = customer.phone;
            balTextBox.Text             = customer.balance.ToString();
            voucherCodeCheckBox.Checked = customer.isVoucherAvailable;
            if (customer.isVoucherAvailable)
            {
                voucherCodeTextBox.Text = customer.voucherCode;
            }
            addresstextBox.Text = customer.address;
            othertextBox.Text   = customer.other;

            editButton.Visible   = true;
            deleteButton.Visible = true;
            addButton.Enabled    = false;

            customerModel = customer;
        }
Exemple #27
0
        public async Task <IActionResult> UpdateCustomer([FromBody] CustomerDataModel customerDataModel)
        {
            try
            {
                if (customerDataModel != null)
                {
                    var customer = await CustomerHandler.UpdateCustomer(customerDataModel);

                    if (customer == null)
                    {
                        return(StatusCode(505, "An unexpected error has ocurred, unable to update Customer"));
                    }
                    Logger.LogWarning("Customer updated");
                    return(Ok(customer));
                }
                return(StatusCode(404));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                return(StatusCode(505, ex.Message));
            }
        }
Exemple #28
0
        public CustomerDataModel GetCustomerData(int id)
        {
            DataTable         dataTable = new DataTable();
            CustomerDataModel customer  = new CustomerDataModel();

            Initialize();

            using (SqlConn)
            {
                SqlConn.Open();

                using (SqlCommand sqlCommand = new SqlCommand(selectCustomerWithId, SqlConn))
                {
                    try
                    {
                        sqlCommand.Parameters.AddWithValue("@val1", id);
                        dataTable.Load(sqlCommand.ExecuteReader());

                        foreach (DataRow row in dataTable.Rows)
                        {
                            customer.FirstName     = row["first_name"].ToString();
                            customer.LastName      = row["last_name"].ToString();
                            customer.Address       = row["address"].ToString();
                            customer.ContactNumber = row["contact_number"].ToString();
                            customer.id            = id;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"Error message: {ex.Message}");
                    }
                }
            }

            return(customer);
        }
        public void SaveCustomerData([FromBody] CustomerDataModel data)
        {
            DataTable dtCustomerData = new DataHelper().PostValues("INSERT INTO CustomerData VALUES ('" + data.CustomerName + "' , '" + data.CustomerEmail + "')");

            return;
        }
        public void UpdateCustomerDetails([FromBody] CustomerDataModel data)
        {
            DataTable dtUsers = new DataHelper().PostValues("UPDATE CustomerData SET CustomerName='" + data.CustomerName + "',CustomerEmail='" + data.CustomerEmail + "' WHERE CustomerID='" + data.CustomerID + "'");

            return;
        }
        private async void processData(bool isEdit)
        {
            string  name      = nametextBox.Text;
            string  phone     = phoneMaskedTextBox.Text;
            bool    isVoucher = voucherCodeCheckBox.Checked;
            string  address   = addresstextBox.Text;
            string  other     = othertextBox.Text;
            decimal bal       = decimal.Parse(balTextBox.Text);

            if (isEdit)
            {
                customerModel.customerName       = name;
                customerModel.phone              = phone;
                customerModel.balance            = bal;
                customerModel.isVoucherAvailable = isVoucher;
                customerModel.address            = address;
                customerModel.voucherCode        = _voucherCode;
                customerModel.other              = other;

                if (!MessagePrompt.displayPrompt("Edit", "edit this Customer"))
                {
                    return;
                }

                MessageBox.Show(await DatabaseOperations.editCustomers(customerModel) ? "Data updated successfully" : "Data updating failed");
            }
            else
            {
                CustomerDataModel customers = new CustomerDataModel()
                {
                    customerName       = name,
                    phone              = phone,
                    isVoucherAvailable = isVoucher,
                    voucherCode        = _voucherCode,
                    address            = address,
                    other              = other,
                    balance            = bal
                };

                if (!MessagePrompt.displayPrompt("Create New", "create new customer"))
                {
                    return;
                }

                bool success = await DatabaseOperations.addCustomers(customers);

                if (success)
                {
                    MessageBox.Show("Customer Created successfully");

                    nametextBox.Clear();
                    balTextBox.Clear();
                    phoneMaskedTextBox.Clear();
                    addresstextBox.Clear();
                    othertextBox.Clear();
                    voucherCodeCheckBox.Checked = false;
                }
            }
            //if (voucherCodeCheckBox.Checked)
            //{
            //    _voucherCode = RandomIDGenerator.randomInt(Constants.VOUCHER_CODE_LENGTH);
            //    voucherCodeTextBox.Text = _voucherCode;
            //    regenerateVoucherbutton.Enabled = true;
            //}
        }