public IActionResult CreateCustomer(CreateCustomerDto customerModel) { var customerNameOrError = CustomerName.Create(customerModel.Name); var customerEmailOrError = CustomerEmail.Create(customerModel.Email); var result = Result.Combine(customerNameOrError, customerEmailOrError); if (result.IsFailure) { return(Error(result.Error)); } if (_customerRepository.GetCustomerByEmail(customerEmailOrError.Value) != null) { return(Error($"[{customerModel.Email}] is already in use.")); } var customer = new Customer(customerNameOrError.Value, customerEmailOrError.Value); _customerRepository.Add(customer); return(Ok()); // return CreatedAtAction(nameof(GetCustomerById), new {id = customerModel.Id}, customerModel); }
public IActionResult AddEmail(long id) { var customer = _db.Customers.FirstOrDefault(c => c.CustomerId == id); if (customer == null) { return(RedirectToAction("List")); } var newEmail = new CustomerEmail { CustomerId = id }; var adding = new AddEditEmailViewModel { AlterEmail = newEmail }; adding = FillEditEmail(customer, adding); if (Request.Headers["X-Requested-With"] == "XMLHttpRequest") { return(PartialView(adding)); } return(View(adding)); }
public async Task <bool> Delete(CustomerEmail CustomerEmail) { if (await ValidateId(CustomerEmail)) { } return(CustomerEmail.IsValidated); }
protected List <object> InitPacket() { List <object> packet = new List <object>() { new { @event = "setAccount", account = AccountId }, new { @event = "setSiteType", type = ClientDevice } }; #region Add Customer Email if (string.IsNullOrEmpty(CustomerEmail)) { packet.Add(new { @event = "setHashedEmail", email = "" }); } else { var customerEmail = CustomerEmail.Trim().ToLowerInvariant(); if (HashEmail) { packet.Add(new { @event = "setHashedEmail", email = GetHashEmail(customerEmail) }); } else { packet.Add(new { @event = "setEmail", email = customerEmail }); } } #endregion return(packet); }
private void clearButton_Click(object sender, EventArgs e) { CustomerName.Clear(); phno.Clear(); CustomerAddress.Clear(); CustomerEmail.Clear(); customerId.Clear(); }
// Override ToString to display useful info in the listbox public override string ToString() { // Determine what the value of shipped is string Shipped = ShippingStatus == true ? "Yes" : "No"; // Output formatted string return($"{InvoiceID, 5}{" ",-20}{CustomerName, -48}{CustomerEmail.Trim(), -34}{Shipped, -8}"); }
public Customer_CustomerEmailDTO(CustomerEmail CustomerEmail) { this.Id = CustomerEmail.Id; this.CustomerId = CustomerEmail.CustomerId; this.Email = CustomerEmail.Email; this.EmailTypeId = CustomerEmail.EmailTypeId; this.EmailType = CustomerEmail.EmailType == null ? null : new Customer_EmailTypeDTO(CustomerEmail.EmailType); this.Errors = CustomerEmail.Errors; }
public async Task <CustomerEmail> Get(long Id) { CustomerEmail CustomerEmail = await DataContext.CustomerEmail.AsNoTracking() .Where(x => x.Id == Id) .Select(x => new CustomerEmail() { Id = x.Id, CustomerId = x.CustomerId, Email = x.Email, EmailTypeId = x.EmailTypeId, Customer = x.Customer == null ? null : new Customer { Id = x.Customer.Id, Code = x.Customer.Code, Name = x.Customer.Name, Phone = x.Customer.Phone, Address = x.Customer.Address, NationId = x.Customer.NationId, ProvinceId = x.Customer.ProvinceId, DistrictId = x.Customer.DistrictId, WardId = x.Customer.WardId, CustomerTypeId = x.Customer.CustomerTypeId, Birthday = x.Customer.Birthday, Email = x.Customer.Email, ProfessionId = x.Customer.ProfessionId, CustomerResourceId = x.Customer.CustomerResourceId, SexId = x.Customer.SexId, StatusId = x.Customer.StatusId, CompanyId = x.Customer.CompanyId, ParentCompanyId = x.Customer.ParentCompanyId, TaxCode = x.Customer.TaxCode, Fax = x.Customer.Fax, Website = x.Customer.Website, NumberOfEmployee = x.Customer.NumberOfEmployee, BusinessTypeId = x.Customer.BusinessTypeId, Investment = x.Customer.Investment, RevenueAnnual = x.Customer.RevenueAnnual, IsSupplier = x.Customer.IsSupplier, Descreption = x.Customer.Descreption, Used = x.Customer.Used, RowId = x.Customer.RowId, }, EmailType = x.EmailType == null ? null : new EmailType { Id = x.EmailType.Id, Code = x.EmailType.Code, Name = x.EmailType.Name, }, }).FirstOrDefaultAsync(); if (CustomerEmail == null) { return(null); } return(CustomerEmail); }
public IActionResult EditEmail(long id, CustomerEmail editEmail, string em = null) { //make sure customer with id exists var requested = _db.Customers.FirstOrDefault(c => c.CustomerId == id); if (ValidCustomerIdAndEmail(requested, id, em) != null) { return(ValidCustomerIdAndEmail(requested, id, em)); } var edited = new AddEditEmailViewModel { AlterEmail = editEmail }; //make sure there is an attatched email to the customer if (_db.Emails.Any(e => e.CustomerId == id)) { //if there is find the one with the associated email id var requestedEmail = _db.Emails.FirstOrDefault(e => e.Email == em); if (requestedEmail == null) { return(RedirectToAction("Profile", "Customer", new { id = id })); } else { var sendBack = FillEditEmail(requested, edited); if (!ModelState.IsValid) { return(View(sendBack)); } if (!string.IsNullOrEmpty(edited.AlterEmail.Email)) { var exists = _db.Emails.FirstOrDefault(e => e.Email == edited.AlterEmail.Email); if (exists == null) { requestedEmail.Email = edited.AlterEmail.Email; _db.SaveChanges(); } else if (exists.Email == em) { requestedEmail.Email = edited.AlterEmail.Email; _db.SaveChanges(); } else { ModelState.AddModelError("", "Email already exists"); return(View(sendBack)); } } } } return(RedirectToAction("Profile", "Customer", new { id = id })); }
public async Task <CustomerEmail> Get(long Id) { CustomerEmail CustomerEmail = await UOW.CustomerEmailRepository.Get(Id); if (CustomerEmail == null) { return(null); } return(CustomerEmail); }
private void showCustomerEdit() { CustomerName.Hide(); customerNameTextBox.Show(); CustomerEmail.Hide(); customerEmailTextBox.Show(); CustomerPhone.Hide(); customerPhoneTextBox.Show(); EditCustomerInfoButton.Hide(); CancelChangeButton.Show(); checkCustomerDataChanged(globalCustomerId); }
private void hideCustomerEdit() { CustomerName.Show(); customerNameTextBox.Hide(); CustomerEmail.Show(); customerEmailTextBox.Hide(); CustomerPhone.Show(); customerPhoneTextBox.Hide(); EditCustomerInfoButton.Show(); CancelChangeButton.Hide(); AcceptChangeButton.Hide(); }
public async Task <bool> Create(CustomerEmail CustomerEmail) { CustomerEmailDAO CustomerEmailDAO = new CustomerEmailDAO(); CustomerEmailDAO.Id = CustomerEmail.Id; CustomerEmailDAO.CustomerId = CustomerEmail.CustomerId; CustomerEmailDAO.Email = CustomerEmail.Email; CustomerEmailDAO.EmailTypeId = CustomerEmail.EmailTypeId; DataContext.CustomerEmail.Add(CustomerEmailDAO); await DataContext.SaveChangesAsync(); CustomerEmail.Id = CustomerEmailDAO.Id; await SaveReference(CustomerEmail); return(true); }
public (bool, CustomerEmail) VerifyLoginDetails(CustomerEmail email) { string query = "select * from customerEmail where Email='" + email.Email + "' AND password = '******'"; using (var connection = OpenConnection()) { var dataReader = ExecuteQueryAsReader(query, connection); CustomerEmail entity = null; if (dataReader.HasRows) { while (dataReader.Read()) { entity = CustomerEmail.CreateEntity(dataReader); } } return(dataReader.HasRows, entity); } }
public async Task <bool> Update(CustomerEmail CustomerEmail) { CustomerEmailDAO CustomerEmailDAO = DataContext.CustomerEmail.Where(x => x.Id == CustomerEmail.Id).FirstOrDefault(); if (CustomerEmailDAO == null) { return(false); } CustomerEmailDAO.Id = CustomerEmail.Id; CustomerEmailDAO.CustomerId = CustomerEmail.CustomerId; CustomerEmailDAO.Email = CustomerEmail.Email; CustomerEmailDAO.EmailTypeId = CustomerEmail.EmailTypeId; await DataContext.SaveChangesAsync(); await SaveReference(CustomerEmail); return(true); }
public async Task <bool> ValidateId(CustomerEmail CustomerEmail) { CustomerEmailFilter CustomerEmailFilter = new CustomerEmailFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = CustomerEmail.Id }, Selects = CustomerEmailSelect.Id }; int count = await UOW.CustomerEmailRepository.Count(CustomerEmailFilter); if (count == 0) { CustomerEmail.AddError(nameof(CustomerEmailValidator), nameof(CustomerEmail.Id), ErrorCode.IdNotExisted); } return(count == 1); }
public async Task <CustomerEmail> Delete(CustomerEmail CustomerEmail) { if (!await CustomerEmailValidator.Delete(CustomerEmail)) { return(CustomerEmail); } try { await UOW.CustomerEmailRepository.Delete(CustomerEmail); await Logging.CreateAuditLog(new { }, CustomerEmail, nameof(CustomerEmailService)); return(CustomerEmail); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerEmailService)); } return(null); }
public IActionResult AddEmail(long id, CustomerEmail addEmail) { var customer = _db.Customers.FirstOrDefault(c => c.CustomerId == id); if (customer == null) { return(RedirectToAction("List")); } var additional = new AddEditEmailViewModel { AlterEmail = addEmail }; // assign in case it doesnt work additional = FillEditEmail(customer, additional); if (!ModelState.IsValid) { return(View(additional)); } if (!string.IsNullOrWhiteSpace(additional.AlterEmail.Email)) { var exists = _db.Emails.FirstOrDefault(e => e.Email == addEmail.Email); if (exists == null) { _db.Add(addEmail); _db.SaveChanges(); } else { ModelState.AddModelError("", "Email already exists"); return(View(additional)); } } return(RedirectToAction("profile", "customer", new { id = id })); }
public async Task <Customer> Get( CustomerDTO inboundCustomer) { var customer = new Customer( inboundCustomer.Username, inboundCustomer.EmailAddress, inboundCustomer.Name); var customerEmail = new CustomerEmail(inboundCustomer.EmailAddress); var transactWriteItemRequest = new TransactWriteItemsRequest { TransactItems = new List <TransactWriteItem>(2) { new TransactWriteItem { Put = new Put { TableName = "OnlineStore-dd006eb", ConditionExpression = "attribute_not_exists(PK)", Item = customer.AsTableItem() } }, new TransactWriteItem { Put = new Put { TableName = "OnlineStore-dd006eb", ConditionExpression = "attribute_not_exists(PK)", Item = customerEmail.AsTableItem() } } } }; var response = await this._client.TransactWriteItemsAsync(transactWriteItemRequest).ConfigureAwait(false); return(customer); }
public IActionResult Create([FromBody] CreateCustomerDto item) { //try //{ var customerNameOrError = CustomerName.Create(item.Name); var customerEmailOrError = CustomerEmail.Create(item.Email); var result = Result.Combine(customerEmailOrError, customerEmailOrError); if (result.IsFailure) { return(Error(result.Error)); } //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} if (_customerRepository.GetByEmail(customerEmailOrError.Value) != null) { return(Error("Email is already in use: " + item.Email)); } var customer = new Customer(customerNameOrError.Value, customerEmailOrError.Value); _customerRepository.Add(customer); //_customerRepository.SaveChanges(); return(Ok()); //} //catch (Exception e) //{ // return StatusCode(500, new { error = e.Message }); //} }
public async Task <CustomerEmail> Update(CustomerEmail CustomerEmail) { if (!await CustomerEmailValidator.Update(CustomerEmail)) { return(CustomerEmail); } try { var oldData = await UOW.CustomerEmailRepository.Get(CustomerEmail.Id); await UOW.CustomerEmailRepository.Update(CustomerEmail); CustomerEmail = await UOW.CustomerEmailRepository.Get(CustomerEmail.Id); await Logging.CreateAuditLog(CustomerEmail, oldData, nameof(CustomerEmailService)); return(CustomerEmail); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(CustomerEmailService)); } return(null); }
public IActionResult Create([FromBody] CreateCustomerDto item) { var customerNameResult = CustomerName.Create(item.Name); var customerEmailResult = CustomerEmail.Create(item.Email); var moneySpent = Money.Create(0); var result = Result.Combine(customerNameResult, customerEmailResult, moneySpent); if (result.IsFailure) { return(Error(result.Error)); } if (_customerRepository.GetByEmail(item.Email) != null) { return(Error("Email is already in use: " + item.Email)); } var newCustomer = new Customer(customerNameResult.Value, customerEmailResult.Value); _customerRepository.Add(newCustomer); return(Ok()); }
public override int GetHashCode() { return(CustomerEmail.GetHashCode() + CompanyINNOGRN.GetHashCode() + TimeStamp.ToShortDateString().GetHashCode()); }
public async Task <bool> Create(CustomerEmail CustomerEmail) { return(CustomerEmail.IsValidated); }
internal void textChanged(object changedString) { switch (changedString as string) { case "name": { if (!string.IsNullOrEmpty(CustomerName) && SelectedRecord == null) { CustomerList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("CustomerName").ToLower().Contains(CustomerName.ToLower())); CustomerList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "mobile": { if (!string.IsNullOrEmpty(CustomerMobile) && SelectedRecord == null) { CustomerList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("mobileNumber").ToLower().Contains(CustomerMobile.ToLower())); CustomerList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "address": { if (!string.IsNullOrEmpty(CustomerAddress) && SelectedRecord == null) { CustomerList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("Address").ToLower().Contains(CustomerAddress.ToLower())); CustomerList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "telegram": { if (!string.IsNullOrEmpty(CustomerTelegram) && SelectedRecord == null) { CustomerList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("whatsappNumber").ToLower().Contains(CustomerTelegram.ToLower())); CustomerList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "email": { if (!string.IsNullOrEmpty(CustomerEmail) && SelectedRecord == null) { CustomerList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("emailID").ToLower().Contains(CustomerEmail.ToLower())); CustomerList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; } }
public Customer GetByEmail(CustomerEmail email) { return(_unitOfWork .Query <Customer>() .SingleOrDefault(x => x.Email == email)); }
public string GenerateReferenceNumber(string userId) { string referenceNo = CustomerEmail.Substring(0, CustomerEmail.LastIndexOf("@")) + userId.Substring(0, 4) + BookingId; return(referenceNo); }
private void submitButton_Click(object sender, EventArgs e) { if (CustomerName.Text == "" || phno.Text == "" || CustomerAddress.Text == "" || CustomerEmail.Text == "" || customerId.Text == "") { MessageBox.Show("Please provide all the details", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (phno.Text.Length != 10) { MessageBox.Show("Enter valid Phone number", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Connect connectObj = new Connect(); con = connectObj.connect(); SqlCommand cmd = new SqlCommand("customer_in", con); //To execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@cid", customerId.Text); cmd.Parameters.AddWithValue("@cname", CustomerName.Text); cmd.Parameters.AddWithValue("@phone_number", Convert.ToInt64(phno.Text)); cmd.Parameters.AddWithValue("@address", CustomerAddress.Text); cmd.Parameters.AddWithValue("@email", CustomerEmail.Text); cid += 1; int i = cmd.ExecuteNonQuery(); if (i != 0) { MessageBox.Show("Customer Insertion Successful!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Customer Insertion Failed", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); //Clear all the textboxes. CustomerName.Clear(); phno.Clear(); CustomerAddress.Clear(); CustomerEmail.Clear(); customerId.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (con != null) { con.Close(); } } }
public IActionResult Create(CreateCustomerViewModel added) { if (!ModelState.IsValid) { return(View()); } // add a new customer to database with current time as creation time var addedCustomer = new Customer { FirstName = added.FirstName, LastName = added.LastName, DateCreated = DateTime.Now }; _db.Customers.Add(addedCustomer); _db.SaveChanges(); //save customer to db and find id created so we can work with this data for //other tables related to customer var newestCustomer = _db.Customers.Last(); //make sure there is information in email field and if so save to the database if (!string.IsNullOrWhiteSpace(added.Email)) { var emailToAdd = new CustomerEmail { Email = added.Email, CustomerId = newestCustomer.CustomerId }; _db.Add(emailToAdd); _db.SaveChanges(); } //make sure there is information in phone field and if so save to the database if (!string.IsNullOrWhiteSpace(added.PhoneNumber)) { var phoneToAdd = new CustomerPhoneNumber { PhoneNumber = added.PhoneNumber, CustomerId = newestCustomer.CustomerId }; _db.Add(phoneToAdd); _db.SaveChanges(); } //create a Customer Address model and fill it var addressToAdd = new CustomerAddress { StreetAddress = added.StreetAddress, City = added.City, ProvState = added.ProvState, Country = added.Country, Postal = added.Postal, CustomerId = newestCustomer.CustomerId }; var checkedAddress = AnyAddressFieldsFilled(addressToAdd); //make sure that one field was filled (if not returned null) if (checkedAddress != null) { _db.Add(checkedAddress); _db.SaveChanges(); } return(RedirectToAction("Profile", "customer", new { id = newestCustomer.CustomerId })); }
private async Task SaveReference(CustomerEmail CustomerEmail) { }