Ejemplo n.º 1
0
 public Customer(int id, string name, string lastName, CustomerStatus status)
 {
     _id = id;
     _name = name;
     _lastName = lastName;
     _status = status;
 }
 public CustomerCreatedEvent(string name, string email,CustomerStatus customerStatus)
 {
     this.EventState = EventState.New;
     this.name = name;
     this.email = email;
     this.customerStatus = customerStatus;
 }
Ejemplo n.º 3
0
        public virtual Dollars CalculatePrice(CustomerStatus status)
        {
            decimal modifier = 1 - status.GetDiscount();

            return(GetBasePrice() * modifier);
        }
 public void SendPromotionalEMail(string email, CustomerStatus status)
 {
     SendMail(email, "Congratulations", "You have been promoted");
 }
Ejemplo n.º 5
0
 public void setStatus(CustomerStatus status)
 {
     this.status = status;
 }
Ejemplo n.º 6
0
 public void AddStatusHistory(CustomerStatus customerStatus, Customer customer, DateTime startDate)
 {
     AddStatusHistory(customerStatus, customer, startDate, (DateTime?)null);
 }
Ejemplo n.º 7
0
		public bool Is(CustomerStatus status)
		{
			return CustomerStatus == status;
		}
Ejemplo n.º 8
0
        public async Task <CustomerResponse <List <CustomerStatus> > > Import(IFormFile formFile, CancellationToken cancellationToken)
        {
            if (formFile == null || formFile.Length <= 0)
            {
                return(CustomerResponse <List <CustomerStatus> > .GetResult(-1, "File này đang rỗng!", 0, 0, null));
            }

            if (!Path.GetExtension(formFile.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase))
            {
                return(CustomerResponse <List <CustomerStatus> > .GetResult(-1, "Loại file này không được hỗ trợ!", 0, 0, null));
            }
            var filename = formFile.FileName;
            var list     = new List <CustomerStatus>();

            using (var stream = new MemoryStream())
            {
                await formFile.CopyToAsync(stream, cancellationToken);

                using (var package = new ExcelPackage(stream))
                {
                    ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
                    var            rowCount  = worksheet.Dimension.Rows;

                    for (int row = 3; row <= rowCount; row++)
                    {
                        Customer customer = new Customer();
                        customer.CustomerCode      = worksheet.Cells[row, 1].Value == null ? "" : worksheet.Cells[row, 1].Value.ToString().Trim();
                        customer.CustomerName      = worksheet.Cells[row, 2].Value == null ? "" : worksheet.Cells[row, 2].Value.ToString().Trim();
                        customer.CustomerMemberId  = worksheet.Cells[row, 3].Value == null ? "" : worksheet.Cells[row, 3].Value.ToString().Trim();
                        customer.CustomerGroupName = worksheet.Cells[row, 4].Value == null ? "" : worksheet.Cells[row, 4].Value.ToString().Trim();
                        customer.PhoneNumber       = worksheet.Cells[row, 5].Value == null ? "" : worksheet.Cells[row, 5].Value.ToString().Trim();
                        customer.CompanyName       = worksheet.Cells[row, 7].Value == null ? "" : worksheet.Cells[row, 7].Value.ToString().Trim();
                        customer.TaxCode           = worksheet.Cells[row, 8].Value == null ? "" : worksheet.Cells[row, 8].Value.ToString().Trim();
                        customer.Email             = worksheet.Cells[row, 9].Value == null ? "" : worksheet.Cells[row, 9].Value.ToString().Trim();
                        customer.Address           = worksheet.Cells[row, 10].Value == null ? "" : worksheet.Cells[row, 10].Value.ToString().Trim();
                        customer.Note = worksheet.Cells[row, 11].Value == null ? "" : worksheet.Cells[row, 11].Value.ToString().Trim();
                        //customer.DateOfBirth = DateTime.Parse(worksheet.Cells[row, 6].Value.ToString().Trim());

                        CustomerStatus customerStatus = new CustomerStatus();
                        customerStatus.Customer = customer;

                        customerStatus.StatusDetail = StatusData(list, customer);
                        if (customerStatus.StatusDetail != "Hợp lệ")
                        {
                            customerStatus.DataIsValid = true;
                        }
                        else
                        {
                            customerStatus.DataIsValid = false;
                        }
                        list.Add(customerStatus);

                        //list.Add(new CustomerStatus
                        //{
                        //    CustomerCode = worksheet.Cells[row, 1].Value.ToString().Trim(),
                        //    CustomerName = worksheet.Cells[row, 2].Value.ToString().Trim(),
                        //    CustomerMemberId = worksheet.Cells[row, 3].Value.ToString().Trim(),
                        //    CustomerGroupName = worksheet.Cells[row, 4].Value.ToString().Trim(),
                        //    PhoneNumber = worksheet.Cells[row, 5].Value.ToString().Trim(),
                        //    //tempDate = worksheet.Cells[row, 6].Value.ToString().Trim(),
                        //    DateOfBirth = DateTime.Parse(worksheet.Cells[row, 6].Value.ToString().Trim()),
                        //    CompanyName = worksheet.Cells[row, 7].Value.ToString().Trim(),
                        //    TaxCode = worksheet.Cells[row, 8].Value.ToString().Trim(),
                        //    Email = worksheet.Cells[row, 9].Value == null ? "" : worksheet.Cells[row, 9].Value.ToString().Trim(),
                        //    Address = worksheet.Cells[row, 10].Value == null ? "" : worksheet.Cells[row, 10].Value.ToString().Trim(),
                        //});
                    }
                }
            }

            // add list to db ..
            // here just read and return

            return(CustomerResponse <List <CustomerStatus> > .GetResult(0, "OK", 0, 0, list));
        }
Ejemplo n.º 9
0
        public Dollar CalculatePrice(CustomerStatus customerStatus)
        {
            var modifier = 1 - customerStatus.Discount;

            return(Price * modifier);
        }
Ejemplo n.º 10
0
 public Result SendPromotionNotification(string email, CustomerStatus newStatus)
 {
     return(SendEmail(email, "Congratulations!", "You've been promoted to " + newStatus));
 }
Ejemplo n.º 11
0
 public InitiationRequirement(UserRole userRole, CustomerStatus customerStatus)
 {
     UserRole       = userRole;
     CustomerStatus = customerStatus;
 }
Ejemplo n.º 12
0
 public void OrderComplete()
 {
     myStatus = CustomerStatus.Eating;
     fxStar.Play();
     SetNextStatusInfos();
 }
 public CustomerStatusChangedEvent(int customerId, CustomerStatus status)
 {
     CustomerId = customerId;
     Status     = status;
 }
Ejemplo n.º 14
0
 public void Promote()
 {
     _status = CustomerStatus.Preferred;
 }
 public Discount(CustomerStatus customerStatus, decimal percentage)
 {
     CustomerStatus = customerStatus;
     Percentage = percentage;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Saves customer status and if necessary the related product.
        /// If the status details for the product already exist, they are deleted
        /// </summary>
        /// <param name="status">The status as supplied by the server</param>
        /// <param name="customer">The customer</param>
        /// <param name="connTran">The connection object for wrapping db calls in a transaction</param>
        /// <returns>A list of all saved items or null if the status was null</returns>
        /// <exception cref="NotSavedException">NotSavedException is thrown if even one item could not be saved</exception>
        public async Task <List <CustomerRegistrationStepsStatus> > SaveAsync(SQLiteConnection connTran, CustomerStatus status, Customer customer)
        {
            if (status == null || status.CustomerNotFound.IsBlank() == false)
            {
                return(null);
            }

            if (status.CustomerProduct.IsBlank())
            {
                status.CustomerProduct = "Product III";
            }

            CriteriaBuilder criteriaBuilder = new CriteriaBuilder();

            criteriaBuilder.Add("DisplayName", status.CustomerProduct);

            string         query    = this.ProductsController.QueryBuilder(criteriaBuilder);
            List <Product> products = await this.ProductsController.SelectQueryAsync(query);

            Product product = null;

            if (products != null)
            {
                product = products.OrderByDescending(prod => prod.Modified).FirstOrDefault();
            }

            List <CustomerRegistrationStepsStatus> resultList = new List <CustomerRegistrationStepsStatus>();

            if (product == null)
            {
                product = new Product
                {
                    DisplayName = status.CustomerProduct
                };

                await this.ProductsController.SaveAsync(connTran, product);
            }
            else
            {
                string sql =
                    string.Format(
                        "Delete from CustomerRegistrationStepsStatus where ProductId='{0}' and CustomerId='{1}'",
                        product.Id, customer.Id);
                await DataAccess.Instance.RunQueryAsync(sql);
            }

            if (status.Steps != null)
            {
                foreach (var step in status.Steps)
                {
                    CustomerRegistrationStepsStatus registrationStepsStatus = new CustomerRegistrationStepsStatus
                    {
                        CustomerId     = customer.Id,
                        ProductId      = product.Id,
                        RequestStatus  = status.RequestStatus,
                        StepName       = step.StepName,
                        StepNumber     = step.StepNumber,
                        StepStatus     = step.StepStatus,
                        AdditionalInfo = status.AdditionalInfo
                    };

                    var saveResponse = await base.SaveAsync(connTran, registrationStepsStatus);

                    if (saveResponse.SavedModel != null)
                    {
                        resultList.Add(saveResponse.SavedModel);
                    }
                    else
                    {
                        throw new NotSavedException();
                    }
                }
            }

            SyncingController syncingController = new SyncingController();
            SyncRecord        syncRecord        = await syncingController.GetSyncRecordAsync(customer.RequestId);

            if (syncRecord != null)
            {
                syncRecord.Status = RecordStatus.Synced;
                await syncingController.SaveAsync(connTran, syncRecord);
            }

            return(resultList);
        }
 public Customer(string name, CustomerStatus status)
 {
     Name = name;
     Status = status;
 }
            public void DeserializeEnumClass(CustomerStatus enum1, string json)
            {
                var enumClass = JsonConvert.DeserializeObject <EnumClass>(json);

                enumClass.CustomerStatus.Should().Be(enum1);
            }
Ejemplo n.º 19
0
 public void SendPromotionNotification(string email, CustomerStatus newStatus)
 {
     PromotionNotificationsSent++;
 }
 partial void UpdateCustomerStatus(CustomerStatus instance);
Ejemplo n.º 21
0
 public Customer(string name, CustomerStatus status, string email)
 {
     Name          = name;
     Status        = status;
     EmailResponse = email;
 }
Ejemplo n.º 22
0
 bool IEmailGateway.SendPromotionNotification(string email, CustomerStatus newStatus)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 23
0
 public void AddToCustomerStatuses(CustomerStatus customerStatus)
 {
     base.AddObject("CustomerStatuses", customerStatus);
 }
Ejemplo n.º 24
0
        public CustomerStatus GetCustomerStatus(int CustomerStatusID)
        {
            var result = new CustomerStatus();

            var response = GetContext().CustomerStatuses
                .Where(c => c.CustomerStatusID == CustomerStatusID)
                .FirstOrDefault();
            if(response == null) return null;

            result.CustomerStatusID = response.CustomerStatusID;
            result.CustomerStatusDescription = response.CustomerStatusDescription;

            return result;
        }
Ejemplo n.º 25
0
        public CustomerStatusDTO Map(CustomerStatus entity)
        {
            var dto = LoadEntityData(entity);

            return(dto);
        }
Ejemplo n.º 26
0
 public static Customer WithStatus(this Customer customer, CustomerStatus status)
 {
     Assert.Equal(status, customer.Status);
     return(customer);
 }
Ejemplo n.º 27
0
        public CustomerStatus GetCustomerStatus(int CustomerStatusID)
        {
            var result = new CustomerStatus();

            using (var reader = GetContext().GetReader(@"
                    SELECT
                        *
                    FROM CustomerStatuses
                    WHERE CustomerStatusID = {0}
                ", CustomerStatusID))
            {
                var closed = reader.IsClosed;
                if(!reader.Read()) return null;

                result.CustomerStatusID = reader.GetInt32("CustomerStatusID");
                result.CustomerStatusDescription = reader.GetString("CustomerStatusDescription");
            }

            return result;
        }
Ejemplo n.º 28
0
 public static CustomerStatus CreateCustomerStatus(int customerStatusID)
 {
     CustomerStatus customerStatus = new CustomerStatus();
     customerStatus.CustomerStatusID = customerStatusID;
     return customerStatus;
 }
Ejemplo n.º 29
0
        public async Task <bool> ShowOverlayIfPhoneNumberDuplicate(string phone, string nationalId = null)
        {
            ErrorFilterFlags flag = ErrorFilterFlags.DisableErrorHandling;
            Person           person;

            SalesApp.Core.BL.Models.People.Customer customer = await new CustomersController().GetPersonIfExists(phone, nationalId, filterFlags: flag, checkDuplicate: false);
            SalesApp.Core.BL.Models.People.Prospect prospect = null;

            if (customer == null)
            {
                prospect = await new ProspectsController().GetPersonIfExists(phone, filterFlags: flag, checkDuplicate: false);
                person   = JsonConvert.DeserializeObject <Person>(JsonConvert.SerializeObject(prospect));
            }
            else
            {
                if (customer.PersonType == PersonTypeEnum.Prospect)
                {
                    prospect =
                        JsonConvert.DeserializeObject <SalesApp.Core.BL.Models.People.Prospect>(
                            JsonConvert.SerializeObject(customer));
                }
                else
                {
                    string         urlParam       = customer.Phone + "&foradditionalproduct=true";
                    CustomerStatus customerStatus = await new CustomerStatusApi().GetAsync(urlParam);

                    if (customerStatus != null)
                    {
                        customer.AccountStatus = customerStatus.AccountStatus;
                    }
                }

                person = JsonConvert.DeserializeObject <Person>(JsonConvert.SerializeObject(customer));
            }

            if (person == null)
            {
                return(false);
            }

            this._fragmentInfo = new FragmentInfo();
            this._fragmentInfo.SetArgument(FragmentInfo.ResourceIdBundleKey, Resource.Layout.fragment_unified_existing_person);

            this._fragmentInfo.ViewCreated += (sender, args) =>
            {
                ViewsHelper <Person> viewsHelper = new ViewsHelper <Person>(Activity as ActivityBase,
                                                                            _fragmentInfo.InflatedView);

                viewsHelper.BindEvent
                (
                    BindableEvents.OnClick
                    , Resource.Id.linEditCustomer
                    , linEditCustomer =>
                {
                    WizardActivity.HideOverlay(true);
                });

                viewsHelper.BindEvent(
                    BindableEvents.OnClick,
                    Resource.Id.linAddProduct,
                    linAddProduct =>
                {
                    // if doing prospect registration, do conversion to customer
                    if (WizardActivity.WizardType == WizardTypes.ProspectRegistration)
                    {
                        // do conversion to customer
                        if (person.PersonType == PersonTypeEnum.Prospect)
                        {
                            ProspectSearchResult psr = JsonConvert.DeserializeObject <ProspectSearchResult>(JsonConvert.SerializeObject(prospect));
                            Dictionary <string, object> bundledItems = new Dictionary <string, object>();
                            bundledItems.Add(KeyProspectIdBundled, psr);

                            WizardLauncher.Launch(Activity, WizardTypes.CustomerRegistration, WizardActivity.StartPoint, bundledItems);
                        }
                        else
                        {
                            // posible additional product
                            if (customer != null)
                            {
                                WizardActivity.HideOverlay(true);
                                IsAdditionalProduct = true;
                                WizardActivity.IsProspectConversion      = true;
                                CustomerSearchResult csr                 = JsonConvert.DeserializeObject <CustomerSearchResult>(JsonConvert.SerializeObject(customer));
                                Dictionary <string, object> bundledItems = new Dictionary <string, object>();
                                bundledItems.Add(KeyCustomerIdBundled, csr);

                                WizardLauncher.Launch(Activity, WizardTypes.CustomerRegistration, WizardActivity.StartPoint, bundledItems);
                            }
                        }
                    }
                    else
                    {
                        // customer registration
                        if (person.PersonType == PersonTypeEnum.Prospect)
                        {
                            // auto fill the details
                            FillFromExistingRecord(prospect);
                            WizardActivity.IsProspectConversion = true;
                        }
                        else
                        {
                            // auto fill the details
                            FillFromExistingRecord(customer);
                        }

                        WizardActivity.HideOverlay(true);
                        IsAdditionalProduct = true; // though this may be cheating ;)
                        WizardActivity.GoNext();
                    }
                });

                viewsHelper.Write(Resource.Id.tvPersonName, person.FullName);
                viewsHelper.Write(Resource.Id.tvPhone, person.Phone);
                viewsHelper.WriteBoundViews(customer);

                if (customer != null && customer.AccountStatus != null && !customer.AccountStatus.Equals("Active"))
                {
                    ShowConversionButton(_fragmentInfo.InflatedView, ViewStates.Gone);
                    ShowPersonStatus(_fragmentInfo.InflatedView);
                }

                if (person.PersonType == PersonTypeEnum.Prospect)
                {
                    // show conversion button
                    ShowConversionButton(_fragmentInfo.InflatedView, ViewStates.Visible);
                }
            };

            WizardActivity.ShowOverlay(_fragmentInfo, false);
            return(true);
        }
Ejemplo n.º 30
0
 public Customer(CustomerStatus status)
 {
     Status = status;
 }
        private async Task <List <CustomerStatus> > CalculateCustomerStatusSummary(List <Account> Accounts, List <AccountSensors> AccountNumSensors)
        {
            var customerStatusList = new List <CustomerStatus>();

            CustomerStatus overDueCustomer = new CustomerStatus();

            overDueCustomer.Status = AppLocalizer.Overdue;
            overDueCustomer.Title  = AppLocalizer.Overdue;
            customerStatusList.Add(overDueCustomer);

            CustomerStatus dueCustomer = new CustomerStatus();

            dueCustomer.Status = AppLocalizer.Due;
            dueCustomer.Title  = AppLocalizer.Due;
            customerStatusList.Add(dueCustomer);

            CustomerStatus renewCustomer = new CustomerStatus();

            renewCustomer.Status = AppLocalizer.Renew;
            renewCustomer.Title  = AppLocalizer.Renew;
            customerStatusList.Add(renewCustomer);

            CustomerStatus newCustomer = new CustomerStatus();

            newCustomer.Status = AppLocalizer.New;
            newCustomer.Title  = AppLocalizer.New;
            customerStatusList.Add(newCustomer);

            foreach (var account in Accounts)
            {
                var numSes = AccountNumSensors.Where(x => x.AccountID == account.AccountID).FirstOrDefault();

                if (numSes != null)
                {
                    switch (GetCustomerStatus(account))
                    {
                    case CustomerStatusEnum.Overdue:

                        overDueCustomer.Count  += 1;
                        overDueCustomer.Amount += await GetSensorAnnualFee(numSes, account.PostalCode);

                        break;

                    case CustomerStatusEnum.Due:

                        dueCustomer.Count  += 1;
                        dueCustomer.Amount += await GetSensorAnnualFee(numSes, account.PostalCode);

                        break;

                    case CustomerStatusEnum.New:

                        newCustomer.Count  += 1;
                        newCustomer.Amount += await GetSensorAnnualFee(numSes, account.PostalCode);

                        break;

                    case CustomerStatusEnum.Renew:

                        renewCustomer.Count  += 1;
                        renewCustomer.Amount += await GetSensorAnnualFee(numSes, account.PostalCode);

                        break;
                    }
                }
            }

            return(customerStatusList);
        }
 public Result SendPromotionNotification(string email, CustomerStatus newStatus)
 {
     PromotionNotificationsSent++;
     return(Result.Success());
 }
Ejemplo n.º 33
0
            }             // Compare

            public EarnedInterestRow(bool bBIsTotal, CustomerStatus nLastInPeriodStatus, CustomerStatus nCurrentStatus)
            {
                m_bIsTotal         = bBIsTotal;
                IssueDate          = ms_oLongAgo;
                ClientID           = 0;
                LoanID             = 0;
                ClientName         = null;
                ClientEmail        = null;
                EarnedInterest     = 0;
                LoanAmount         = 0;
                TotalRepaid        = 0;
                PrincipalRepaid    = 0;
                m_oClientCount     = new SortedDictionary <int, int>();
                m_oLoanCount       = new SortedDictionary <int, int>();
                LastInPeriodStatus = nLastInPeriodStatus;
                CurrentStatus      = nCurrentStatus;
                SetupFees          = 0;
                OtherFees          = 0;
                Rollover           = 0;
            }             // constructor
 public ICustomer CreateCustomer(string name, CustomerStatus status)
 {
     return new Customer(name, status);
 }
 public ChangeCustomerStatusCommand(int customerId, CustomerStatus status)
 {
     CustomerId = customerId;
     Status     = status;
 }
        private void ResolveNullValueForEnumField(JsonPatchDocument <CustomerInformation> customerInfo)
        {
            foreach (var item in customerInfo.Operations)
            {
                if (item.ParsedPath.Last().Name.Equals("PhoneType"))
                {
                    PhoneType phoneType = PhoneType.NotSpecified;
                    var       value     = item.Value == null?PhoneType.NotSpecified.ToString() : item.Value.ToString();

                    if (Enum.TryParse <PhoneType>(value, out phoneType))
                    {
                        item.Value = value;
                    }
                    else
                    {
                        item.Value = PhoneType.NotSpecified.ToString();
                    }
                }

                if (item.ParsedPath.Last().Name.Equals("EmailType"))
                {
                    EmailType emailType = EmailType.NotSpecified;
                    var       value     = item.Value == null?EmailType.NotSpecified.ToString() : item.Value.ToString();

                    if (Enum.TryParse <EmailType>(value, out emailType))
                    {
                        item.Value = value;
                    }
                    else
                    {
                        item.Value = EmailType.NotSpecified.ToString();
                    }
                }

                if (item.ParsedPath.Last().Name.Equals("CustomerStatus"))
                {
                    CustomerStatus customerStatus = CustomerStatus.NotSpecified;
                    var            value          = item.Value == null?CustomerStatus.NotSpecified.ToString() : item.Value.ToString();

                    if (Enum.TryParse <CustomerStatus>(value, out customerStatus))
                    {
                        item.Value = value;
                    }
                    else
                    {
                        item.Value = CustomerStatus.NotSpecified.ToString();
                    }
                }
                if (item.ParsedPath.Last().Name.Equals("Gender"))
                {
                    Gender gender = Gender.NotSpecified;
                    var    value  = item.Value == null?Gender.NotSpecified.ToString() : item.Value.ToString();

                    if (Enum.TryParse <Gender>(value, out gender))
                    {
                        item.Value = value;
                    }
                    else
                    {
                        item.Value = Gender.NotSpecified.ToString();
                    }
                }
            }
        }
 public Discount GetDiscountForCustomerStatus(CustomerStatus customerStatus)
 {
     return _discounts.First(record => record.CustomerStatus == customerStatus);
 }
Ejemplo n.º 38
0
 public bool Is(CustomerStatus status)
 {
     return(CustomerStatus == status);
 }
Ejemplo n.º 39
0
 public CustomerAdded(Guid id, string name, CustomerStatus status)
 {
     Id     = id;
     Name   = name;
     Status = status;
 }
 partial void InsertCustomerStatus(CustomerStatus instance);
Ejemplo n.º 41
0
 static CustomerStatus()
 {
     Standard = new CustomerStatus(0);
     Prime    = new CustomerStatus(0.1m);
 }
 partial void DeleteCustomerStatus(CustomerStatus instance);
Ejemplo n.º 43
0
 private Customer(int customerId, Address primaryAddress, CustomerStatus status)
 {
     CustomerId     = customerId;
     PrimaryAddress = primaryAddress;
     Status         = CustomerStatus.New;
 }
Ejemplo n.º 44
0
        public async Task <ResponseDto <Customer> > SetCustomerStatus(int customerId, CustomerStatus customerStatus)
        {
            var customer = await _dbContext.Customers.FindAsync(customerId);

            if (customer == null)
            {
                var errorDto      = new ErrorDto("The customer was not found.");
                var errorResponse = new ResponseDto <Customer>(errorDto);

                return(errorResponse);
            }

            customer.Status = customerStatus;
            await _dbContext.SaveChangesAsync();

            var responseDto = new ResponseDto <Customer>(customer);

            return(responseDto);
        }
        public static ISubscription CreateSubscriptionWithDefaultCustomer(ISubscriptionRegistration subscriptionRegistration, ICustomerRegistration customerRegistration, string phoneNumber, string countryIsoCode, CustomerStatus status)
        {
            var customer = customerRegistration.CreateCustomer("John Doe", status);

            return subscriptionRegistration.CreateSubscription(customer,phoneNumber, countryIsoCode);
        }