Example #1
0
        public GetCustomersResponse GetCustomers(GetCustomersRequest request)
        {
            try
            {
                var response = new GetCustomersResponse();

                // Real code goes here...
                //response.CustomerList.Add(new Customer { Name = "Markus Egger", Company = "CODE" });
                //response.CustomerList.Add(new Customer { Name = "Ellen Whitney", Company = "CODE" });
                //response.CustomerList.Add(new Customer { Name = "Mike Yeager", Company = "CODE" });
                //response.CustomerList.Add(new Customer { Name = "Otto Dobretsberger", Company = "CODE" });

                response.CustomerList = new Customer[] {
                    new Customer {
                        Name = "Markus Egger", Company = "CODE"
                    },
                    new Customer {
                        Name = "Ellen Whitney", Company = "CODE"
                    },
                    new Customer {
                        Name = "Mike Yeager", Company = "CODE"
                    },
                    new Customer {
                        Name = "Otto Dobretsberger", Company = "CODE"
                    }
                };

                response.Success = true;
                return(response);
            }
            catch (Exception ex)
            {
                return(ServiceHelper.GetPopulatedFailureResponse <GetCustomersResponse>(ex));
            }
        }
Example #2
0
        public HttpResponseMessage GetCustomers()
        {
            GetCustomersResponse responseData = null;

            try
            {
                //Authenticate API key
                long?hostId = HostServices.GetCallerHostId();
                if (!hostId.HasValue)
                {
                    Log.Warn(ResponseMessages.InvalidAPIKey);
                    return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.InvalidAPIKey, ResponseMessages.InvalidAPIKey)));
                }

                //Perform transaction
                CustomerServices customerServices = new CustomerServices();
                var customers = customerServices.GetCustomers(hostId.Value);

                responseData           = new GetCustomersResponse();
                responseData.Customers = customers;

                //Send response
                return(Request.CreateResponse(new GenericResponse(responseData, ResponseCodes.Success, ResponseMessages.Success)));
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                return(Request.CreateResponse(new GenericResponse(null, ResponseCodes.Error, ResponseMessages.Error)));
            }
        }
        public void TestGetCustomers()
        {
            int customerId = 1;
            GetCustomersResponse response = new GetCustomersResponse();

            response.Customers.Add(new CustomerListDTO()
            {
                Id = customerId
            });

            Expect.Once.On(service).Method("GetCustomersByCriteria").Will(Return.Value(response));
            IList <CustomerListDTO> customers = serviceFacade.GetCustomersByCity("FakeCity");

            Assert.AreEqual(1, customers.Count);
            Assert.AreEqual(customers.First().Id, customerId);

            Expect.Once.On(service).Method("GetCustomersByCriteria").Will(Return.Value(response));
            customers = serviceFacade.GetCustomersByName("FAkeName");
            Assert.AreEqual(1, customers.Count);
            Assert.AreEqual(customers.First().Id, customerId);

            Expect.Once.On(service).Method("GetCustomersByCriteria").Will(Return.Value(response));
            customers = serviceFacade.GetAllCustomers();
            Assert.AreEqual(1, customers.Count);
            Assert.AreEqual(customers.First().Id, customerId);
        }
Example #4
0
 private void SingleAccount(int id)
 {
     ApiRequest = new GetCustomersRequest()
     {
         CustomerStatuses = new int[] { 1 },
         CustomerID       = id
     };
     ApiResponse = new GetCustomersResponse();
 }
Example #5
0
 private void AccountsFromLast2Days()
 {
     ApiRequest = new GetCustomersRequest()
     {
         BatchSize        = 500,
         CreatedDateStart = DateTime.Now.Subtract(TimeSpan.FromDays(2)),
         CustomerStatuses = new int[] { 1 }
     };
     ApiResponse = new GetCustomersResponse();
 }
Example #6
0
 private void AccountsGreaterThanID(int id)
 {
     ApiRequest = new GetCustomersRequest()
     {
         BatchSize             = 50000,
         CustomerStatuses      = new int[] { 1 },
         GreaterThanCustomerID = id
     };
     ApiResponse = new GetCustomersResponse();
 }
Example #7
0
 private void AccountsGreaterThanModfiedDate(DateTime modifiedDate)
 {
     ApiRequest = new GetCustomersRequest()
     {
         BatchSize               = 50000,
         CustomerStatuses        = new int[] { 1 },
         GreaterThanModifiedDate = modifiedDate
     };
     ApiResponse = new GetCustomersResponse();
 }
Example #8
0
 private void TerminatedAccounts()
 {
     ApiRequest = new GetCustomersRequest()
     {
         BatchSize             = 50000,
         CustomerStatuses      = new int[] { 2 },
         GreaterThanCustomerID = 5
     };
     ApiResponse = new GetCustomersResponse();
 }
Example #9
0
 private void AccountsCreatedAfter(DateTime createdDate)
 {
     ApiRequest = new GetCustomersRequest()
     {
         BatchSize             = 50000,
         CustomerStatuses      = new int[] { 1 },
         GreaterThanCustomerID = 5
     };
     ApiResponse = new GetCustomersResponse();
 }
Example #10
0
        public GetCustomersResponse GetCustomersByCriteria(GetCustomersRequest request)
        {
            GetCustomersResponse      response = new GetCustomersResponse();
            CustomerBusinessComponent bc       = DependencyInjectionHelper.GetCustomerBusinessComponent();

            IQueryable <Customer> customers = bc.GetCustomersByCriteria(request.SearchType, request.City, request.CustomerName);

            response.Customers = CustomerAdapter.CustomersToDtos(customers);

            return(response);
        }
Example #11
0
        public async Task <IHttpActionResult> Get()
        {
            GetCustomersResponse response = await _customerService.GetCustomersAsync();

            if (response.Success)
            {
                return(Ok <IEnumerable <Customer> >(response.Customers));
            }

            return(InternalServerError(response.OperationException));
        }
Example #12
0
        public GetCustomersResponse GetAllCustomers()
        {
            string key = "GetAllCustomers";
            GetCustomersResponse response = _cacheStorage.Retrieve <GetCustomersResponse>(key);

            if (response == null)
            {
                int cacheDurationSeconds = _configurationRepository.GetConfigurationValue <int>("ShortCacheDuration");
                response = _innerCustomerService.GetAllCustomers();
                _cacheStorage.Store(key, response, TimeSpan.FromSeconds(cacheDurationSeconds));
            }
            return(response);
        }
Example #13
0
        public SocketMessage HadleMessage(GetCustomersRequest msg)
        {
            var response = new GetCustomersResponse();

            if (msg.CustomerIDs == null)
            {
                response.Customers = _context.Customers.ToList();
            }
            else
            {
                response.Customers = _context.Customers.Where(c => msg.CustomerIDs.Contains(c.Id)).ToList();
            }
            return(response);
        }
Example #14
0
        public JsonResult FindCustomers(QuickSearchRequest request)
        {
            GetGeneralResponse <IEnumerable <CustomerView> > response = _customerService.FindCustomers(request, GetEmployee().ID);

            // فعلا به فرمت قدیم پاس می دهیم
            GetCustomersResponse cresponse = new GetCustomersResponse()
            {
                CustomerViews = response.data,
                success       = true,
                TotalCount    = response.totalCount
            };

            return(Json(cresponse, JsonRequestBehavior.AllowGet));
        }
Example #15
0
        public GetCustomersResponse GetAllCustomers()
        {
            GetCustomersResponse   getCustomersResponse = new GetCustomersResponse();
            IEnumerable <Customer> allCustomers         = null;

            try
            {
                allCustomers = _customerRepository.FindAll();
                getCustomersResponse.Customers = allCustomers.ConvertToViewModels();
            }
            catch (Exception ex)
            {
                getCustomersResponse.Exception = ex;
            }
            return(getCustomersResponse);
        }
Example #16
0
 public void HadleMessage(GetCustomersResponse msg)
 {
     foreach (var customer in msg.Customers)
     {
         var oldCustomer = _dataContext.Customers.SingleOrDefault(c => c.Id == customer.Id);
         if (oldCustomer != null)
         {
             oldCustomer.Name    = customer.Name;
             oldCustomer.Balance = customer.Balance;
         }
         else
         {
             _dataContext.Customers.Add(new CustomerViewModel(customer));
         }
     }
 }
Example #17
0
        public SocketMessage HadleMessage(ChangeBalanceRequest msg)
        {
            var customer = _context.Customers.SingleOrDefault(c => c.Id == msg.CustomerID);

            if (customer != null)
            {
                customer.Balance += msg.Difference;
                _context.SaveChanges();
            }
            var response = new GetCustomersResponse();

            response.Customers = new List <Customer>()
            {
                customer
            };
            return(response);
        }
 private IList <CustomerListDTO> getCustomers(CustomerSearchType searchType, string name, string city)
 {
     try
     {
         GetCustomersRequest request = new GetCustomersRequest();
         request.SearchType   = searchType;
         request.CustomerName = name;
         request.City         = city;
         GetCustomersResponse response = Service.GetCustomersByCriteria(request);
         return(response.Customers);
     }
     catch (Exception ex)
     {
         if (ExceptionPolicy.HandleException(ex, "PL Policy"))
         {
             throw;
         }
         return(new List <CustomerListDTO>());
     }
 }
Example #19
0
        private Event ApiGetEventDetails(int eventId)
        {
            // TODO: Fix this hack.  Dependency injection is no longer working on AJAX calls?
            if (null == Api)
            {
                Api = ExigoService.Exigo.WebService();
            }

            var eventCustomerResponse = Api.GetCustomers(new GetCustomersRequest
            {
                CustomerID    = eventId,
                CustomerTypes = new int[] { (int)CustomerTypes.Party }
            });

            Customer eventCustomer = null;

            if (null != eventCustomerResponse &&
                null != eventCustomerResponse.Customers &&
                0 != eventCustomerResponse.Customers.Length)
            {
                eventCustomer = Mapper.Map <Customer>(eventCustomerResponse.Customers[0]);
            }
            else
            {
                throw new ApplicationException("The provided event ID does not exist.");
            }

            var eventCustomerSiteResponse = Api.GetCustomerSite(new GetCustomerSiteRequest
            {
                CustomerID = eventId
            });

            if (ResultStatus.Failure.Equals(eventCustomerSiteResponse.Result.Status))
            {
                throw new ApplicationException("There an error while retrieving the details of the event ID provided.");
            }

            var eventCustomerExResponse = Api.GetCustomerExtended(new GetCustomerExtendedRequest
            {
                CustomerID      = eventId,
                ExtendedGroupID = (int)CustomerExtendedGroup.PartyDetails, // Party Extended Fields
            });

            CustomerExtendedResponse eventCustomerEx = null;

            if (ResultStatus.Success.Equals(eventCustomerExResponse.Result.Status) &&
                null != eventCustomerExResponse.Items &&
                0 != eventCustomerExResponse.Items.Length)
            {
                eventCustomerEx = eventCustomerExResponse.Items[0];
            }
            else
            {
                throw new ApplicationException("There an error while retrieving the details of the event ID provided.");
            }

            GetCustomersResponse creatorCustomerResponse = null;
            int creatorCustomerId = 0;

            if (int.TryParse(eventCustomerEx.Field5, out creatorCustomerId))
            {
                creatorCustomerResponse = Api.GetCustomers(new GetCustomersRequest
                {
                    CustomerID    = creatorCustomerId,
                    CustomerTypes = new int[] { (int)CustomerTypes.IndependentStyleAmbassador }
                });
            }

            Customer creator = null;

            if (ResultStatus.Success.Equals(creatorCustomerResponse.Result.Status) &&
                null != creatorCustomerResponse.Customers &&
                0 != creatorCustomerResponse.Customers.Length)
            {
                creator = Mapper.Map <Customer>(creatorCustomerResponse.Customers[0]);

                try
                {
                    var creatorCustomerSiteResponse = Api.GetCustomerSite(new GetCustomerSiteRequest
                    {
                        CustomerID = creator.CustomerID
                    });
                    creator.WebAlias = creatorCustomerSiteResponse.WebAlias;
                }
                catch { }
            }

            GetCustomersResponse hostCustomerResponse = null;
            int hostCustomerId = 0;

            if (int.TryParse(eventCustomerEx.Field6, out hostCustomerId))
            {
                hostCustomerResponse = Api.GetCustomers(new GetCustomersRequest
                {
                    CustomerID = hostCustomerId
                });
            }

            Customer host = null;

            if (ResultStatus.Success.Equals(hostCustomerResponse.Result.Status) &&
                null != hostCustomerResponse.Customers &&
                0 != hostCustomerResponse.Customers.Length)
            {
                host = Mapper.Map <Customer>(hostCustomerResponse.Customers[0]);
            }

            // Retrieve the party sales total
            var salesTotal = GetPointAccountBalance(eventId, PointAccounts.PartySalesTotal);

            // Retieve the Host' rewards point accounts
            var pointAccounts = GetHostRewardPointAccounts(eventId);

            //var bookingRewards = GetBookingRewards();

            //int bookingRewardsOwnerId = 0;
            //int.TryParse(eventCustomerEx.Field7, out bookingRewardsOwnerId);

            // Create Missing Host Specials
            CreateMissngHostSpecials(eventCustomerEx);


            var @event = new Event()
            {
                Id                 = eventCustomer.CustomerID,
                Name               = eventCustomer.FirstName,
                Location           = eventCustomer.MainAddress,
                MainAddress1       = eventCustomer.MainAddress.Address1,
                MainAddress2       = eventCustomer.MainAddress.Address2,
                MainCity           = eventCustomer.MainAddress.City,
                MainState          = eventCustomer.MainAddress.State,
                MainZip            = eventCustomer.MainAddress.Zip,
                MainCountry        = eventCustomer.MainAddress.Country,
                Creator            = creator,
                Host               = host,
                IsNewGT            = true,
                HostFullName       = host.FirstName + " " + host.LastName,
                CreatorFullName    = creator.FirstName + " " + creator.LastName,
                HostId             = host.CustomerID.ToString(),
                HostEmail          = host.Email,
                HostPhone          = host.Phone,
                CreatorId          = creator.CustomerID.ToString(),
                TotalSales         = salesTotal,
                EventPointAccounts = null != pointAccounts?pointAccounts.ToArray() : null,
                                         //EventBookingRewards = bookingRewards,
                                         //BookingRewardsOwnerId = bookingRewardsOwnerId,
                                         WebAlias          = eventCustomerSiteResponse.WebAlias,
                                         StartDate         = Convert.ToDateTime(eventCustomerEx.Field1),
                                         ActualDate        = Convert.ToDateTime(eventCustomerEx.Field2),
                                         EventStatus       = eventCustomer.CustomerStatusID == 0 ? "Close" : Convert.ToDateTime(eventCustomerEx.Field4) < DateTime.Now ? "Close" : "Open",
                                         CloseDate         = Convert.ToDateTime(eventCustomerEx.Field3),
                                         LockoutDate       = Convert.ToDateTime(eventCustomerEx.Field4),
                                         PartyDate         = string.IsNullOrEmpty(eventCustomerEx.Field12) ? Convert.ToDateTime(eventCustomerEx.Field2) : Convert.ToDateTime(eventCustomerEx.Field12),
                                         PartyStartTime    = string.IsNullOrEmpty(eventCustomerEx.Field13) ? DateTime.Parse(eventCustomerEx.Field2) : DateTime.Parse(eventCustomerEx.Field13),
                                         PartyEndTime      = string.IsNullOrEmpty(eventCustomerEx.Field14) ? DateTime.Parse(eventCustomerEx.Field2).AddHours(1) : DateTime.Parse(eventCustomerEx.Field14),
                                         TimeZone          = string.IsNullOrEmpty(eventCustomerEx.Field15) ? "(UTC-06:00) Central Time (US & Canada)" : eventCustomerEx.Field15,
                                         DeletedEvents     = eventCustomer.CustomerStatusID == 0 ? true : false,
                                         HostSpecialReward = (HostSpecialDiscount)eventCustomerEx,
            };

            if ((@event.LockoutDate - @event.CloseDate).TotalDays <= 2.00)
            {
                @event.LockoutDate = @event.CloseDate.AddDays(7);
            }
            return(@event);
        }