Exemple #1
0
        public ActionResult <IEnumerable <Reason> > Get()
        {
            var reasons = _reasonService.GetReasons();
            var result  = _mapper.Map <IEnumerable <Model.Reason>, IEnumerable <Reason> >(reasons);

            return(Ok(result));
        }
        /// <summary>
        /// Method to get reasons
        /// </summary>
        /// <param name="reasonType">Reason type</param>
        /// <returns>List of reasons</returns>
        public List <Return_Reason> GetReasons(ReasonType reasonType)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,ReasonManager,GetReasons,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var type    = (char)reasonType;
            var reasons = new List <Return_Reason>();
            var store   = CacheManager.GetStoreInfo();
            var offSet  = store?.OffSet ?? 0;

            if (type != '\0')
            {
                reasons = _reasonService.GetReasons(type);
            }
            if (reasons == null || reasons.Count == 0)
            {
                reasons = new List <Return_Reason>
                {
                    new Return_Reason
                    {
                        Description = _resourceManager.GetResString(offSet, 207), //"<No reasons defined>"
                        Reason      = "0"
                    }
                };
            }
            Performancelog.Debug($"End,ReasonManager,GetReasons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(reasons);
        }
        /// <summary>
        /// Method to get payout vendor
        /// </summary>
        /// <param name="error">Error</param>
        /// <returns>Vendor payout</returns>
        public VendorPayout GetPayoutVendor(out ErrorMessage error)
        {
            error = new ErrorMessage();
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            if (!_policyManager.DO_PAYOUTS)
            {
                MessageType temp_VbStyle8 = (int)MessageType.Exclamation + MessageType.OkOnly;
                error.MessageStyle = _resourceManager.CreateMessage(offSet, 38, 54, null, temp_VbStyle8);
                return(null);
            }
            var vendorPayout = new VendorPayout();
            var po           = new Payout();
            var taxes        = po.Payout_Taxes;

            _taxManager.Load_Taxes(ref taxes);
            int totals = 0;

            foreach (Payout_Tax tax in taxes)
            {
                if (totals >= 4)
                {
                    MessageType temp_VbStyle = (int)MessageType.Information + MessageType.OkOnly;
                    vendorPayout.Message = _resourceManager.CreateMessage(offSet, 23, 90, null, temp_VbStyle);
                    break;
                }

                if (tax.Tax_Active)
                {
                    vendorPayout.Taxes.Add(new Tax
                    {
                        Description = _resourceManager.GetResString(offSet, 194) + tax.Tax_Name,
                        Code        = tax.Tax_Name,
                        Amount      = 0
                    });
                    totals++;
                }
            }
            var vendors = _stockService.GetAllVendors();

            foreach (var vendor in vendors)
            {
                vendorPayout.Vendors.Add(new PayoutVendor
                {
                    Code = vendor.Code,
                    Name = vendor.Name
                });
            }
            var reasons = _reasonService.GetReasons((char)ReasonType.Payouts);

            foreach (Return_Reason reason in reasons)
            {
                vendorPayout.Reasons.Add(new VendorReason
                {
                    Code        = reason.Reason,
                    Description = reason.Description
                });
            }
            return(vendorPayout);
        }