예제 #1
0
        public async Task <ACMGenericResult <DispatchChannel> > GetDispatchChannel(string dispatchId)
        {
            var result = new ACMGenericResult <DispatchChannel>();

            try
            {
                AccountConfiguration accountConfiguration = await ViaMongoDB.GetAccountConfiguration();

                if (accountConfiguration.DispatchChannels == null)
                {
                    result.StatusCode = 204;
                    result.Value      = null;
                }
                else
                {
                    DispatchChannel dispatchChannel = accountConfiguration.DispatchChannels.Find(x => x.DispatchId == dispatchId);
                    if (dispatchChannel == default)
                    {
                        result.StatusCode = 204;
                        result.Value      = null;
                    }
                    else
                    {
                        result.StatusCode = 200;
                        result.Value      = dispatchChannel;
                    }
                }
            }
            catch (Exception)
            {
                result.StatusCode = 500;
                result.Value      = null;
            }
            return(result);
        }
예제 #2
0
        public async Task <ACMGenericResult <Dictionary <string, string> > > UpdateExtendedProperties(Dictionary <string, string> extendedProperties)
        {
            var result = new ACMGenericResult <Dictionary <string, string> >();

            try
            {
                result.StatusCode = 200;
                result.Value      = (await ViaMongoDB.UpdateAccountConfiguration_ExtendedProperties(extendedProperties)).ExtendedProperties;
            }
            catch (Exception)
            {
                result.StatusCode = 500;
                result.Value      = null;
            }
            return(result);
        }
예제 #3
0
        public async Task <ACMGenericResult <string> > DeleteAccountConfiguration()
        {
            var deleteResponseObj = new ACMGenericResult <string>();

            try
            {
                await ViaMongoDB.DeleteAccountConfiguration();

                deleteResponseObj.StatusCode = 200;
                deleteResponseObj.Value      = "Account has been cleared";
            }
            catch (Exception)
            {
                deleteResponseObj.StatusCode = 500;
                deleteResponseObj.Value      = null;
            }
            return(deleteResponseObj);
        }
예제 #4
0
        public async Task <ACMGenericResult <DispatchesAndQueueDetails> > GetDispatches(string bearerToken)
        {
            var result = new ACMGenericResult <DispatchesAndQueueDetails>();

            try
            {
                List <Dispatch> dispatches = await WXMService.GetDispatches(bearerToken);

                List <DeliveryPlan> deliveryPlans = await WXMService.GetDeliveryPlans(bearerToken) ?? new List <DeliveryPlan>();

                List <Question> preFillQuestions = (await WXMService.GetActiveQuestions(bearerToken)).Where(x => x.StaffFill == true)?.ToList() ?? new List <Question>();
                Settings        settings         = await WXMService.GetSettings(bearerToken);

                if (dispatches?.Count > 0 == false || settings == null)
                {
                    result.StatusCode = 400;
                    result.Value      = null;
                }
                else
                {
                    var configuredDispatchChannels = await ConfigureDispatchChannels(dispatches, deliveryPlans, preFillQuestions);

                    var configuredQueue = await ConfigureQueueDetails(settings);

                    result.StatusCode = 200;
                    result.Value      = new DispatchesAndQueueDetails
                    {
                        Dispatches = configuredDispatchChannels?
                                     .Select(x => new KeyValuePair <string, string>(x.DispatchId, x.DispatchName))?
                                     .ToList() ?? new List <KeyValuePair <string, string> >(),
                        Queue = configuredQueue
                    };
                }
            }
            catch (Exception)
            {
                result.StatusCode = 500;
                result.Value      = null;
            }
            return(result);
        }
예제 #5
0
        public async Task <ACMGenericResult <Vendor> > AddOrUpdateVendor(Vendor newVendor)
        {
            var result = new ACMGenericResult <Vendor>();

            try
            {
                AccountConfiguration accountConfiguration = await ViaMongoDB.GetAccountConfiguration();

                if (accountConfiguration.Vendors == null)
                {
                    accountConfiguration.Vendors = new List <Vendor> {
                        newVendor
                    }
                }
                ;
                else
                {
                    int index = accountConfiguration.Vendors.FindIndex(x => string.Equals(x.VendorName, newVendor.VendorName));
                    if (index == -1)
                    {
                        accountConfiguration.Vendors.Add(newVendor);
                    }
                    else
                    {
                        accountConfiguration.Vendors[index] = ToClone(newVendor);
                    }
                }
                result.StatusCode = 200;
                result.Value      = (await ViaMongoDB.UpdateAccountConfiguration_Vendors(accountConfiguration.Vendors))
                                    .Vendors.Find(x => string.Equals(x.VendorName, newVendor.VendorName));
            }
            catch (Exception)
            {
                result.StatusCode = 500;
                result.Value      = null;
            }
            return(result);
        }
예제 #6
0
        public async Task <ACMGenericResult <DispatchChannel> > AddOrUpdateDispatchChannel(DispatchChannel dispatchChannel)
        {
            var result = new ACMGenericResult <DispatchChannel>();

            try
            {
                AccountConfiguration accountConfiguration = await ViaMongoDB.GetAccountConfiguration();

                if (accountConfiguration.DispatchChannels == null)
                {
                    accountConfiguration.DispatchChannels = new List <DispatchChannel> {
                        dispatchChannel
                    }
                }
                ;
                else
                {
                    int index = accountConfiguration.DispatchChannels.FindIndex(x => x.DispatchId == dispatchChannel.DispatchId);
                    if (index == -1)
                    {
                        accountConfiguration.DispatchChannels.Add(dispatchChannel);
                    }
                    else
                    {
                        accountConfiguration.DispatchChannels[index] = ToClone(dispatchChannel);
                    }
                }
                result.StatusCode = 200;
                result.Value      = (await ViaMongoDB.UpdateAccountConfiguration_DispatchChannels(accountConfiguration.DispatchChannels))
                                    .DispatchChannels?.Find(x => x.DispatchId == dispatchChannel.DispatchId);
            }
            catch (Exception)
            {
                result.StatusCode = 500;
                result.Value      = null;
            }
            return(result);
        }
예제 #7
0
        public async Task <ACMGenericResult <Vendor> > GetVendor(string vendorName)
        {
            var result = new ACMGenericResult <Vendor>();

            try
            {
                AccountConfiguration accountConfiguration = await ViaMongoDB.GetAccountConfiguration();

                if (accountConfiguration.Vendors == null)
                {
                    result.StatusCode = 204;
                    result.Value      = null;
                }
                else
                {
                    Vendor vendor = accountConfiguration.Vendors
                                    .Find(x => string.Equals(x.VendorName, vendorName, StringComparison.InvariantCultureIgnoreCase));
                    if (vendor == default)
                    {
                        result.StatusCode = 204;
                        result.Value      = null;
                    }
                    else
                    {
                        result.StatusCode = 200;
                        result.Value      = vendor;
                    }
                }
            }
            catch (Exception)
            {
                result.StatusCode = 500;
                result.Value      = null;
            }
            return(result);
        }