Beispiel #1
0
        public static string SynchPoint(int customerId)
        {
            IMemberCardService     memberCardService     = DependencyResolver.Current.GetService <IMemberCardService>();
            IMemberCardTypeService memberCardTypeService = DependencyResolver.Current.GetService <IMemberCardTypeService>();
            var points = SqlHelper.QuerySP <HistoryPointViewModel>("spSale_HistoryPoint", new
            {
                CustomerId = customerId
            });

            if (points != null && points.Count() > 0)
            {
                var point = points.FirstOrDefault();
                if (point.MemberCardId != null)
                {
                    var memberCard     = memberCardService.Get(point.MemberCardId.Value);
                    var memberCardType = memberCardTypeService.GetByPoint(point.AccumulatedPoint);
                    if (memberCardType != null)
                    {
                        memberCard.MemberCardTypeId = memberCardType.Id;
                        memberCardService.Update(memberCard);
                    }
                }
            }
            return(null);
        }
Beispiel #2
0
        public static string SynchUpdateTypeCrad(int customerId, double?accumulated, double?used, int?frequency, bool addition = true)
        {
            ICustomerRepository    CustomerRepository    = DependencyResolver.Current.GetService <ICustomerRepository>();
            IMemberCardService     memberCardService     = DependencyResolver.Current.GetService <IMemberCardService>();
            IMemberCardTypeService memberCardTypeService = DependencyResolver.Current.GetService <IMemberCardTypeService>();
            var      customer  = CustomerRepository.GetCustomerById(customerId);
            DateTime aDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

            if (customer != null)
            {
                if (addition)
                {
                    customer.Point         += accumulated;
                    customer.PaidPoint     += used;
                    customer.RemainingPoint = customer.Point - customer.PaidPoint;
                }
                else
                {
                    customer.Point         -= accumulated;
                    customer.PaidPoint     -= used;
                    customer.RemainingPoint = customer.Point - customer.PaidPoint;
                }
                if (frequency != null)
                {
                    customer.Frequency             = frequency;
                    customer.EndDateProductInvoice = aDateTime;
                }
                CustomerRepository.UpdateCustomer(customer);
                if (customer.MemberCardId != null)
                {
                    var memberCard     = memberCardService.Get(customer.MemberCardId.Value);
                    var memberCardType = memberCardTypeService.GetByPoint(customer.Point);
                    if (memberCardType != null)
                    {
                        memberCard.MemberCardTypeId = memberCardType.Id;
                        memberCardService.Update(memberCard);
                    }
                }
            }
            return(null);
        }