Example #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);
        }
 public CustomerController(
     ICustomerRepository _Customer
     , IContactRepository _Contact
     , IUserRepository _user
     , IProductInvoiceRepository _ProductInvoice
     , IvwProvinceService _ProvinceService
     , IvwDistrictService _DistrictService
     , IvwWardService _IWardService
     , IMemberCardService _MemberCardService
     , IvwCarService _vwCarService
     , ICarLineRepository _CarLine
     , ICarsService _Cars
     , IMemberCardTypeService _MemberCardTypeService
     )
 {
     ContactRepository        = _Contact;
     CustomerRepository       = _Customer;
     userRepository           = _user;
     productInvoiceRepository = _ProductInvoice;
     ProvinceService          = _ProvinceService;
     DistrictService          = _DistrictService;
     WardService           = _IWardService;
     MemberCardService     = _MemberCardService;
     vwCarsService         = _vwCarService;
     CarLineRepository     = _CarLine;
     CarsService           = _Cars;
     MemberCardTypeService = _MemberCardTypeService;
 }
Example #3
0
 public MemberCardController(
     IMemberCardService _MemberCard
     , IvwMemberCardService _vwMemberCard
     , IMemberCardTypeService _MemberCardTypeService
     , IUserRepository _user
     , ICustomerRepository _CustomerRepository
     )
 {
     MemberCardService     = _MemberCard;
     vwMemberCardService   = _vwMemberCard;
     MemberCardTypeService = _MemberCardTypeService;
     userRepository        = _user;
     CustomerRepository    = _CustomerRepository;
 }
Example #4
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);
        }
Example #5
0
 public MembersController(IMemberService memberService, IMemberCardService memberCardService)
 {
     this.memberService     = memberService;
     this.memberCardService = memberCardService;
 }
Example #6
0
 public MemberCardController(IAuthorizationService authorizationService,
                             IMemberCardService memberCardService)
 {
     _authorizationService = authorizationService;
     _memberCardService    = memberCardService;
 }