async public Task <bool> GetDiscounts()
        {
            bool isSuccess = false;

            try
            {
                AppData.Discount.DiscountCollection.Clear();

                var token = await Get(RequestDiscounts);

                var branchList = JsonConvert.DeserializeObject <List <Object> >(token);

                foreach (var item in branchList)
                {
                    var          deserializeBranch = JsonConvert.DeserializeObject <DeserializeBranchItem>(item.ToString());
                    DiscountData discountData      = new DiscountData(deserializeBranch);
                    //AppData.Discount.DiscountCollection.Add(discountData);

                    await AppData.Discount.DB.SaveDiscount(discountData);
                }

                isSuccess = true;
            }
            catch (Exception ex)
            {
                isSuccess = false;
            }

            return(isSuccess);
        }
        async public Task <bool> GetPartnerDetail(DiscountData discountData)
        {
            bool isSuccess = false;

            try
            {
                var token = await Get(String.Format(RequestPartnerDetail, discountData.DocumentId));

                var branchList = JsonConvert.DeserializeObject <List <Object> >(token);

                foreach (var item in branchList)
                {
                    var deserializeBranch = JsonConvert.DeserializeObject <DeserializeBranchItem>(item.ToString());
                    await AppData.Discount.DB.UpdateDiscount(deserializeBranch);
                }

                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;
            }

            return(isSuccess);
        }
Exemple #3
0
        async private void OpenPage(DiscountData discountData)
        {
            try
            {
                IsOpenning = true;

                if (Device.OS != TargetPlatform.Android)
                {
                    (ViewPage as DiscountPage).DiscountListView.HideAnimation();
                }

                try
                {
                    IsLoadActivity = true;
                    await AppData.Discount.LoadFullDescription(discountData);
                }
                finally
                {
                    IsLoadActivity = false;
                }

                await ViewPage.Navigation.PushAsync(new DiscountDetailPage(discountData.DocumentId), true);
            }
            finally
            {
                IsOpenning = false;
            }
        }
Exemple #4
0
 public void Setup()
 {
     _expectedEmployees = EmployeeData.GetEmployees();
     _expectedBenefits  = BenefitData.GetBenefits();
     _expectedDiscounts = DiscountData.GetDiscounts();
     _translator        = new CostReportTranslator();
 }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Type = {(Type == null ? "null" : Type.ToString())}");
     toStringOutput.Add($"Id = {(Id == null ? "null" : Id == string.Empty ? "" : Id)}");
     toStringOutput.Add($"UpdatedAt = {(UpdatedAt == null ? "null" : UpdatedAt == string.Empty ? "" : UpdatedAt)}");
     toStringOutput.Add($"Version = {(Version == null ? "null" : Version.ToString())}");
     toStringOutput.Add($"IsDeleted = {(IsDeleted == null ? "null" : IsDeleted.ToString())}");
     toStringOutput.Add($"CustomAttributeValues = {(CustomAttributeValues == null ? "null" : CustomAttributeValues.ToString())}");
     toStringOutput.Add($"CatalogV1Ids = {(CatalogV1Ids == null ? "null" : $"[{ string.Join(", ", CatalogV1Ids)} ]")}");
     toStringOutput.Add($"PresentAtAllLocations = {(PresentAtAllLocations == null ? "null" : PresentAtAllLocations.ToString())}");
     toStringOutput.Add($"PresentAtLocationIds = {(PresentAtLocationIds == null ? "null" : $"[{ string.Join(", ", PresentAtLocationIds)} ]")}");
     toStringOutput.Add($"AbsentAtLocationIds = {(AbsentAtLocationIds == null ? "null" : $"[{ string.Join(", ", AbsentAtLocationIds)} ]")}");
     toStringOutput.Add($"ImageId = {(ImageId == null ? "null" : ImageId == string.Empty ? "" : ImageId)}");
     toStringOutput.Add($"ItemData = {(ItemData == null ? "null" : ItemData.ToString())}");
     toStringOutput.Add($"CategoryData = {(CategoryData == null ? "null" : CategoryData.ToString())}");
     toStringOutput.Add($"ItemVariationData = {(ItemVariationData == null ? "null" : ItemVariationData.ToString())}");
     toStringOutput.Add($"TaxData = {(TaxData == null ? "null" : TaxData.ToString())}");
     toStringOutput.Add($"DiscountData = {(DiscountData == null ? "null" : DiscountData.ToString())}");
     toStringOutput.Add($"ModifierListData = {(ModifierListData == null ? "null" : ModifierListData.ToString())}");
     toStringOutput.Add($"ModifierData = {(ModifierData == null ? "null" : ModifierData.ToString())}");
     toStringOutput.Add($"TimePeriodData = {(TimePeriodData == null ? "null" : TimePeriodData.ToString())}");
     toStringOutput.Add($"ProductSetData = {(ProductSetData == null ? "null" : ProductSetData.ToString())}");
     toStringOutput.Add($"PricingRuleData = {(PricingRuleData == null ? "null" : PricingRuleData.ToString())}");
     toStringOutput.Add($"ImageData = {(ImageData == null ? "null" : ImageData.ToString())}");
     toStringOutput.Add($"MeasurementUnitData = {(MeasurementUnitData == null ? "null" : MeasurementUnitData.ToString())}");
     toStringOutput.Add($"SubscriptionPlanData = {(SubscriptionPlanData == null ? "null" : SubscriptionPlanData.ToString())}");
     toStringOutput.Add($"ItemOptionData = {(ItemOptionData == null ? "null" : ItemOptionData.ToString())}");
     toStringOutput.Add($"ItemOptionValueData = {(ItemOptionValueData == null ? "null" : ItemOptionValueData.ToString())}");
     toStringOutput.Add($"CustomAttributeDefinitionData = {(CustomAttributeDefinitionData == null ? "null" : CustomAttributeDefinitionData.ToString())}");
     toStringOutput.Add($"QuickAmountsSettingsData = {(QuickAmountsSettingsData == null ? "null" : QuickAmountsSettingsData.ToString())}");
 }
        public void ActivateFunction(Store s)
        {
            var discountId   = MarketRules.Instance.CreateSimpleDiscountAsync(s, username, storeId, discountType, precent, category, productId, originalDiscountId: originDiscountId).Result;
            var discountData = new DiscountData(discountId, username, storeId, discountType, RuleType.Simple, precent, category, productId, int.MaxValue, 0, default(DateTime), default(DateTime));

            MarketRulesService.Instance.discountsManager.AddDiscount(discountData).Wait();
        }
        public void ActivateFunction(Store s)
        {
            var discountId   = MarketRules.Instance.CreateConditionalDiscountAsync(s, username, storeId, discountType, ruleType, precent, category, productId, valueLessThan, valueGreaterEQThan, d1, d2, originalDiscountId: originDiscountId).Result;
            var discountData = new DiscountData(originDiscountId, username, storeId, discountType, ruleType, precent, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);

            MarketRulesService.Instance.discountsManager.AddDiscount(discountData).Wait();
        }
            async public Task <bool> LoadFullDescription(DiscountData discountData)
            {
                bool isSuccess = false;

                try
                {
                    if (discountData.IsFullDescription)
                    {
                        isSuccess = true;
                    }
                    else
                    if ((isConnected) && (discountData != null))
                    {
                        isSuccess = await ServiceProvider.GetPartnerDetail(discountData);
                    }
                }
                catch (Exception)
                {
                    //TODO: Handling exception

                    isSuccess = false;
                }

                return(isSuccess);
            }
        public async Task SaveDiscount(DiscountData discount)
        {
            database.BeginTransaction();
            string logoFileName = discount.DocumentId + PostfixLogoFileName;

            await SaveImage(logoFileName, discount.Icon);

            Discount discountDBData = new Discount
            {
                UrlAddress        = discount.UrlAddress,
                IsFullDescription = false,
                DocumentId        = discount.DocumentId,
                LogoFileName      = logoFileName
            };

            discountDBData.PercentValue = discount.DiscountPercent;

            database.Insert(discountDBData);

            //name
            foreach (var name in discount.NameList)
            {
                LangString langStringRec = new LangString {
                    LanguageCode = LanguageHelper.LangEnumToCode(name.Key).ToUpper(), Text = name.Value
                };
                database.Insert(langStringRec);

                DiscountsStrings discountsStringsRec = new DiscountsStrings {
                    Appointment = StrAppointmentTitle, OwnerId = discountDBData.Id, LangStringId = langStringRec.Id
                };
                database.Insert(discountsStringsRec);
            }

            //description
            foreach (var name in discount.DescriptionList)
            {
                LangString langStringRec = new LangString {
                    LanguageCode = LanguageHelper.LangEnumToCode(name.Key).ToUpper(), Text = name.Value
                };
                database.Insert(langStringRec);

                DiscountsStrings discountsStringsRec = new DiscountsStrings {
                    Appointment = StrAppointmentDescription, OwnerId = discountDBData.Id, LangStringId = langStringRec.Id
                };
                database.Insert(discountsStringsRec);
            }

            //categories
            foreach (var categorie in discount.CategorieList)
            {
                Categorie categorieRec = new Categorie {
                    DiscountId = discountDBData.Id, TypeCode = categorie.TypeCode
                };
                database.Insert(categorieRec);
            }

            database.Commit();
        }
        //Add New / Complex Discounts
        public async Task <Guid> AddSimpleDiscountAsync(string username, Guid storeId, RuleContext discountType, double precent, string category = "", Guid productId = new Guid())
        {
            Guid discountId = await marketRules.CreateSimpleDiscountAsync(await MarketStores.Instance.GetStoreById(storeId), username, storeId, discountType, precent, category, productId);

            await StorePredicatesManager.Instance.SaveRequest(++counter, "CreateSimpleDiscountAsync", username, storeId, discountType, precent, category, productId, discountId);

            var discountData = new DiscountData(discountId, username, storeId, discountType, RuleType.Simple, precent, category, productId, int.MaxValue, 0, default(DateTime), default(DateTime));
            await discountsManager.AddDiscount(discountData);

            return(discountId);
        }
Exemple #11
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                foreach (var discount in DiscountData.ReadDiscounts())
                {
                    Discounts.Add(discount);
                }
            }
        }
Exemple #12
0
 public static Discount MapDiscount(DiscountData discount)
 {
     return(new Discount
     {
         Id = discount.Id,
         Description = discount.Description,
         ItemRequiredForDiscountId = discount.ItemRequiredForDiscountId,
         AmountOfRequiredItems = discount.AmountOfRequiredItems,
         DiscountedItemId = discount.DiscountedItemId,
         DiscountAmount = discount.DiscountAmount
     });
 }
        public async Task <Guid> AddConditionalDiscountAsync(string username, Guid storeId, RuleContext discountType, RuleType ruleType, double precent, string category = "", Guid productId = new Guid(),
                                                             double valueLessThan = int.MaxValue, double valueGreaterEQThan = 0, DateTime d1 = default(DateTime), DateTime d2 = default(DateTime))
        {
            Guid discountId = await marketRules.CreateConditionalDiscountAsync(await MarketStores.Instance.GetStoreById(storeId), username, storeId, discountType, ruleType, precent, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);

            await StorePredicatesManager.Instance.SaveRequest(++counter, "CreateConditionalDiscountAsync", username, storeId, discountType, ruleType, precent, category, productId, valueLessThan, valueGreaterEQThan, d1, d2, discountId);

            var discountData = new DiscountData(discountId, username, storeId, discountType, ruleType, precent, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);
            await discountsManager.AddDiscount(discountData);

            return(discountId);
        }
Exemple #14
0
        /// <summary>
        ///     Creates a connection using token.
        /// </summary>
        /// <param name="companyId">Company context</param>
        /// <param name="token">The predefined token from Visma.net</param>
        /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param>
        public VismaNet(int companyId, string token, int branchId = 0)
        {
            if (string.IsNullOrEmpty(token))
            {
                throw new InvalidArgumentsException("Token is missing");
            }

            Auth = new VismaNetAuthorization
            {
                Token     = token,
                CompanyId = companyId,
                BranchId  = branchId
            };
            Attribute                = new AttributeData(Auth);
            Customer                 = new CustomerData(Auth);
            Currency                 = new CurrencyData(Auth);
            CustomerInvoice          = new CustomerInvoiceData(Auth);
            Supplier                 = new SupplierData(Auth);
            SupplierInvoice          = new SupplierInvoiceData(Auth);
            CashSale                 = new CashSaleData(Auth);
            CustomerDocument         = new CustomerDocumentData(Auth);
            Dimension                = new DimensionData(Auth);
            Discount                 = new DiscountData(Auth);
            Inventory                = new InventoryData(Auth);
            JournalTransaction       = new JournalTransactionData(Auth);
            GeneralLedgerTransaction = new GeneralLedgerTransactionData(Auth);
            GeneralLedgerBalance     = new GeneralLedgerBalanceData(Auth);
            Account         = new FinAccountData(Auth);
            FinancialPeriod = new FinancialPeriodData(Auth);
            Employee        = new EmployeeData(Auth);
            Shipment        = new ShipmentData(Auth);
            Contact         = new ContactData(Auth);
            Project         = new ProjectData(Auth);
#pragma warning disable CS0618 // Type or member is obsolete
            SalesOrder = new SalesOrderData(Auth);
#pragma warning restore CS0618 // Type or member is obsolete
            Branch             = new BranchData(Auth);
            Warehouse          = new WarehouseData(Auth);
            Location           = new LocationData(Auth);
            Subaccount         = new SubaccountData(Auth);
            CustomerPayment    = new CustomerPaymentData(Auth);
            Dynamic            = new VismaNetDynamicEndpoint(null, Auth);
            Resources          = new VismaNetDynamicEndpoint(null, Auth, true);
            SupplierDocument   = new SupplierDocumentData(Auth);
            InventoryIssue     = new InventoryIssueData(Auth);
            InventoryReceipt   = new InventoryReceiptData(Auth);
            PurchaseReceipt    = new PurchaseReceiptData(Auth);
            CustomerSalesPrice = new CustomerSalesPriceData(Auth);
            CustomerCreditNote = new CustomerCreditNoteData(Auth);
            PurchaseOrder      = new PurchaseOrderData(Auth);
            CashTransaction    = new CashTransactionData(Auth);
        }
Exemple #15
0
        public async void OnDiscountItemTapped(object sender, ItemTappedEventArgs e)
        {
            DiscountData discountData = e.Item as DiscountData;

            ((ListView)sender).SelectedItem = null;

            ViewPage.Appearing += AnimateListView_Appearing;

            if ((discountData != null) && (!IsOpenning))
            {
                OpenPage(discountData);
            }
        }
        private static void RebindLogoImage(CachedImage imgCompanyLogo, DiscountData viewModel)
        {
            imgCompanyLogo.Source = null;

            var imagePath = viewModel != null
                ? (string)FileNameConverter.Convert(viewModel.LogoFileName, typeof(string), false,
                                                    CultureInfo.CurrentCulture)
                : null;

            if (!string.IsNullOrEmpty(imagePath))
            {
                imgCompanyLogo.Source = imagePath;
            }
        }
        public void LoadDiscount()
        {
            AppData.Discount.DiscountCollection.Clear();

            foreach (var discountRec in database.Table <Discount>())
            {
                DiscountData discountData = new DiscountData();
                discountData.DocumentId        = discountRec.DocumentId;
                discountData.DiscountPercent   = discountRec.PercentValue;
                discountData.IsFullDescription = discountRec.IsFullDescription;
                discountData.LogoFileName      = discountRec.LogoFileName;

                var categoryList = from c in database.Table <Categorie>()
                                   where c.DiscountId == discountRec.Id
                                   select c;
                foreach (var categoryrec in categoryList)
                {
                    discountData.CategorieList.Add(new CategorieData {
                        TypeCode = categoryrec.TypeCode
                    });
                }

                var nameList = (from ds in database.Table <DiscountsStrings>()
                                from ls in database.Table <LangString>()
                                where ds.LangStringId == ls.Id
                                where ds.OwnerId == discountRec.Id
                                where ds.Appointment == StrAppointmentTitle
                                select new { ls.Text, ls.LanguageCode }).ToList();

                foreach (var nameRec in nameList)
                {
                    discountData.SetName(nameRec.LanguageCode, nameRec.Text);
                }

                var descrList = (from ds in database.Table <DiscountsStrings>()
                                 from ls in database.Table <LangString>()
                                 where ds.LangStringId == ls.Id
                                 where ds.OwnerId == discountRec.Id
                                 where ds.Appointment == StrAppointmentDescription
                                 select new { ls.Text, ls.LanguageCode }).ToList();

                foreach (var descrRec in descrList)
                {
                    discountData.SetDescription(descrRec.LanguageCode, descrRec.Text);
                }

                AppData.Discount.DiscountCollection.Add(discountData);
            }
        }
        /// <summary>
        /// 优惠列表查询
        /// </summary>
        public ActionResult DiscountList(DiscountListSearchModel search)
        {
            DiscountListViewModel model = new DiscountListViewModel();                                                         //页面模型

            model.search             = search;                                                                                 //页面的搜索模型
            model.search.PageSize    = 15;                                                                                     //每页显示
            model.search.CurrentPage = Convert.ToInt32(Request["pageindex"]) <= 0 ? 1 : Convert.ToInt32(Request["pageindex"]); //当前页
            //按钮下拉项
            List <CommonEntity> SourceIL = CommonData.GetDictionaryList(15);                                                   //1是字典类型值,仅供测试参考

            model.SourceIL = CommonData.Instance.GetBropDownListData(SourceIL);

            model.Discountlist = DiscountData.GetDiscountList(search); //填充页面模型数据
            return(View(model));                                       //返回页面模型
        }
        /// <summary>
        /// 根据 ID获取按钮详细信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public JsonResult GetDiscountID(int id)
        {
            AjaxStatusModel ajax = new AjaxStatusModel();    //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;              //默认失败
            ajax.msg    = "获取失败!";                           //前台获取,用于显示提示信息
            Discount btn = DiscountData.GetDiscountByID(id); //业务层获取底层方法,返回数据

            if (btn != null)
            {
                ajax.data   = btn;//放入数据
                ajax.status = EnumAjaxStatus.Success;
                ajax.msg    = "获取成功!";
            }
            return(Json(ajax));
        }
Exemple #20
0
        private static Task <List <DiscountData> > LoadDiscounts(
            IEnumerable <Discount> discountsTable,
            IReadOnlyCollection <DiscountCategory> discountCategoriesTable,
            IReadOnlyCollection <DiscountsStrings> discountsStringsTable,
            IReadOnlyCollection <LangString> langStringsTable)
        {
            var result = new List <DiscountData>();

            foreach (var discount in discountsTable)
            {
                var categories = discountCategoriesTable.Where(i => i.DiscountId == discount.Id)
                                 .Join(AppData.Discount.CategoryCollection, i => i.CategoryId, i => i.DocumentId, (dc, c) => c)
                                 .ToList();

                var discountData = new DiscountData
                {
                    DocumentId      = discount.DocumentId,
                    DiscountPercent = discount.PercentValue,
                    DiscountType    = discount.DiscountType.GetDiscountTypeName(),
                    LogoFileName    = discount.LogoFileName,
                    CategoryList    = categories,
                    ModifiedDate    = discount.Modified ?? DateTime.MinValue
                };

                var nameList = discountsStringsTable
                               .Where(i => i.OwnerId == discount.Id && i.Appointment == StrAppointmentTitle)
                               .Join(langStringsTable, i => i.LangStringId, i => i.Id, (ds, ls) => ls);

                foreach (var nameRec in nameList)
                {
                    discountData.SetName(nameRec.LanguageCode, nameRec.Text);
                }

                var descrList = discountsStringsTable
                                .Where(i => i.OwnerId == discount.Id && i.Appointment == StrAppointmentDescription)
                                .Join(langStringsTable, i => i.LangStringId, i => i.Id, (ds, ls) => ls);

                foreach (var descrRec in descrList)
                {
                    discountData.SetDescription(descrRec.LanguageCode, descrRec.Text);
                }

                result.Add(discountData);
            }

            return(Task.FromResult(result));
        }
Exemple #21
0
        public DiscountData GetDiscountData(string id)
        {
            DiscountData discountData = null;

            if (int.TryParse(id, out var integerId) &&
                integerId >= 0 &&
                integerId < HardcodedData.Discounts.Count)
            {
                discountData = HardcodedData.Discounts[integerId];
            }
            else
            {
                Console.WriteLine($"Discount with the ID = {id} does not exist in the data collection");
            }

            return(discountData);
        }
 public static DiscountDataDTO FromDiscountData(DiscountData discountData)
 {
     return(new DiscountDataDTO
     {
         Id = discountData.DiscountId,
         SerialNumber = discountData.SerialNumber,
         Creator = discountData.Username,
         DiscountType = discountData.DiscountType.ToString(),
         ConditionType = discountData.RuleType == RuleType.Simple ? null : discountData.RuleType.ToString(),
         Percent = discountData.Precent,
         Category = discountData.Category,
         ProductId = discountData.ProductId,
         MinValue = discountData.ValueGreaterEQThan == 0 ? null : (int?)discountData.ValueGreaterEQThan,
         MaxValue = discountData.ValueLessThan == int.MaxValue ? null : (int?)discountData.ValueLessThan,
         StartDate = discountData.D1 == default ? null : (DateTime?)discountData.D1,
         EndDate = discountData.D2 == default ? null : (DateTime?)discountData.D2,
     });
        public void LoadDiscounts(
            IEnumerable <Discount> discountsTable,
            IReadOnlyCollection <DiscountCategory> discountCategoriesTable,
            IReadOnlyCollection <DiscountsStrings> discountsStringsTable,
            IReadOnlyCollection <LangString> langStringsTable)
        {
            var discountCollection = new List <DiscountData>();

            foreach (var discount in discountsTable)
            {
                var categories = discountCategoriesTable.Where(i => i.DiscountId == discount.Id)
                                 .Join(AppData.Discount.CategoryCollection, i => i.CategoryId, i => i.DocumentId, (dc, c) => c)
                                 .ToList();

                var discountData = new DiscountData
                {
                    DocumentId      = discount.DocumentId,
                    DiscountPercent = discount.PercentValue,
                    DiscountType    = discount.DiscountType.GetDiscountTypeName(),
                    LogoFileName    = discount.LogoFileName,
                    CategoryList    = categories
                };

                var nameList = discountsStringsTable
                               .Where(i => i.OwnerId == discount.Id && i.Appointment == StrAppointmentTitle)
                               .Join(langStringsTable, i => i.LangStringId, i => i.Id, (ds, ls) => ls);

                foreach (var nameRec in nameList)
                {
                    discountData.SetName(nameRec.LanguageCode, nameRec.Text);
                }

                var descrList = discountsStringsTable
                                .Where(i => i.OwnerId == discount.Id && i.Appointment == StrAppointmentDescription)
                                .Join(langStringsTable, i => i.LangStringId, i => i.Id, (ds, ls) => ls);

                foreach (var descrRec in descrList)
                {
                    discountData.SetDescription(descrRec.LanguageCode, descrRec.Text);
                }

                discountCollection.Add(discountData);
            }

            AppData.Discount.DiscountCollection = discountCollection;
        }
        //Update Simple / Complex Discounts
        public async Task <Result <Guid> > UpdateSimpleDiscountAsync(Guid existingDiscountId, string username, Guid storeId, RuleContext discountType, double precent, string category = "", Guid productId = new Guid())
        {
            if (discountsManager.IsComplexed(existingDiscountId))
            {
                return(new Result <Guid>(new Guid(), true, "Impossible to update a discount which other discounts are complexed on."));
            }
            var res = await marketRules.UpdateSimpleDiscountAsync(await MarketStores.Instance.GetStoreById(storeId), existingDiscountId, username, storeId, discountType, precent, category, productId);

            Guid discountId = res.Ret;
            await StorePredicatesManager.Instance.SaveRequest(++counter, existingDiscountId, "UpdateSimpleDiscountAsync", username, storeId, discountType, precent, category, productId, discountId);

            var discountData = new DiscountData(discountId, username, storeId, discountType, RuleType.Simple, precent, category, productId, int.MaxValue, 0, default(DateTime), default(DateTime));
            await discountsManager.RemoveDiscount(discountId);

            await discountsManager.AddDiscount(discountData);

            return(res);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CatalogObject other &&
                   ((Type == null && other.Type == null) || (Type?.Equals(other.Type) == true)) &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)) &&
                   ((Version == null && other.Version == null) || (Version?.Equals(other.Version) == true)) &&
                   ((IsDeleted == null && other.IsDeleted == null) || (IsDeleted?.Equals(other.IsDeleted) == true)) &&
                   ((CustomAttributeValues == null && other.CustomAttributeValues == null) || (CustomAttributeValues?.Equals(other.CustomAttributeValues) == true)) &&
                   ((CatalogV1Ids == null && other.CatalogV1Ids == null) || (CatalogV1Ids?.Equals(other.CatalogV1Ids) == true)) &&
                   ((PresentAtAllLocations == null && other.PresentAtAllLocations == null) || (PresentAtAllLocations?.Equals(other.PresentAtAllLocations) == true)) &&
                   ((PresentAtLocationIds == null && other.PresentAtLocationIds == null) || (PresentAtLocationIds?.Equals(other.PresentAtLocationIds) == true)) &&
                   ((AbsentAtLocationIds == null && other.AbsentAtLocationIds == null) || (AbsentAtLocationIds?.Equals(other.AbsentAtLocationIds) == true)) &&
                   ((ImageId == null && other.ImageId == null) || (ImageId?.Equals(other.ImageId) == true)) &&
                   ((ItemData == null && other.ItemData == null) || (ItemData?.Equals(other.ItemData) == true)) &&
                   ((CategoryData == null && other.CategoryData == null) || (CategoryData?.Equals(other.CategoryData) == true)) &&
                   ((ItemVariationData == null && other.ItemVariationData == null) || (ItemVariationData?.Equals(other.ItemVariationData) == true)) &&
                   ((TaxData == null && other.TaxData == null) || (TaxData?.Equals(other.TaxData) == true)) &&
                   ((DiscountData == null && other.DiscountData == null) || (DiscountData?.Equals(other.DiscountData) == true)) &&
                   ((ModifierListData == null && other.ModifierListData == null) || (ModifierListData?.Equals(other.ModifierListData) == true)) &&
                   ((ModifierData == null && other.ModifierData == null) || (ModifierData?.Equals(other.ModifierData) == true)) &&
                   ((TimePeriodData == null && other.TimePeriodData == null) || (TimePeriodData?.Equals(other.TimePeriodData) == true)) &&
                   ((ProductSetData == null && other.ProductSetData == null) || (ProductSetData?.Equals(other.ProductSetData) == true)) &&
                   ((PricingRuleData == null && other.PricingRuleData == null) || (PricingRuleData?.Equals(other.PricingRuleData) == true)) &&
                   ((ImageData == null && other.ImageData == null) || (ImageData?.Equals(other.ImageData) == true)) &&
                   ((MeasurementUnitData == null && other.MeasurementUnitData == null) || (MeasurementUnitData?.Equals(other.MeasurementUnitData) == true)) &&
                   ((SubscriptionPlanData == null && other.SubscriptionPlanData == null) || (SubscriptionPlanData?.Equals(other.SubscriptionPlanData) == true)) &&
                   ((ItemOptionData == null && other.ItemOptionData == null) || (ItemOptionData?.Equals(other.ItemOptionData) == true)) &&
                   ((ItemOptionValueData == null && other.ItemOptionValueData == null) || (ItemOptionValueData?.Equals(other.ItemOptionValueData) == true)) &&
                   ((CustomAttributeDefinitionData == null && other.CustomAttributeDefinitionData == null) || (CustomAttributeDefinitionData?.Equals(other.CustomAttributeDefinitionData) == true)) &&
                   ((QuickAmountsSettingsData == null && other.QuickAmountsSettingsData == null) || (QuickAmountsSettingsData?.Equals(other.QuickAmountsSettingsData) == true)));
        }
Exemple #26
0
        async public void MapLocation_ClickPinDetail(object sender, MapPinDataEventArgs e)
        {
            MapPinData   pinData      = e.PinData;
            DiscountData discountData = AppData.Discount.DiscountCollection.Find(item => { return(item.DocumentId == pinData.PartnerId); });

            if (discountData != null)
            {
                try
                {
                    IsLoadActivity = true;
                    await AppData.Discount.LoadFullDescription(discountData);
                }
                finally
                {
                    IsLoadActivity = false;
                }

                await ViewPage.Navigation.PushAsync(new DiscountDetailPage(discountData.DocumentId), true);
            }
        }
        /// <summary>
        /// 保存编辑按钮
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public JsonResult SaveDiscount()
        {
            AjaxStatusModel ajax = new AjaxStatusModel(); //功能操作类的返回类型都是AjaxStatusModel,数据放到AjaxStatusModel.data中,前台获取json后加载

            ajax.status = EnumAjaxStatus.Error;           //默认失败
            ajax.msg    = "保存失败!";                        //前台获取,用于显示提示信息
            var data = Request["data"];                   //获取前台传递的数据,主要序列化

            if (string.IsNullOrEmpty(data))
            {
                return(Json(ajax));
            }
            Discount Dis = (Discount)(JsonConvert.DeserializeObject(data.ToString(), typeof(Discount)));

            Dis.UpdateTime = DateTime.Now;        //修改时间
            Dis.UpdatorId  = UserSession.userid;  //修改人
            if (DiscountData.UpdateDiscount(Dis)) //注意时间类型,而且需要在前台把所有的值
            {
                ajax.msg    = "保存成功!";
                ajax.status = EnumAjaxStatus.Success;
            }
            return(Json(ajax));
        }
        public override int GetHashCode()
        {
            int hashCode = -1814270990;

            if (Type != null)
            {
                hashCode += Type.GetHashCode();
            }

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (UpdatedAt != null)
            {
                hashCode += UpdatedAt.GetHashCode();
            }

            if (Version != null)
            {
                hashCode += Version.GetHashCode();
            }

            if (IsDeleted != null)
            {
                hashCode += IsDeleted.GetHashCode();
            }

            if (CustomAttributeValues != null)
            {
                hashCode += CustomAttributeValues.GetHashCode();
            }

            if (CatalogV1Ids != null)
            {
                hashCode += CatalogV1Ids.GetHashCode();
            }

            if (PresentAtAllLocations != null)
            {
                hashCode += PresentAtAllLocations.GetHashCode();
            }

            if (PresentAtLocationIds != null)
            {
                hashCode += PresentAtLocationIds.GetHashCode();
            }

            if (AbsentAtLocationIds != null)
            {
                hashCode += AbsentAtLocationIds.GetHashCode();
            }

            if (ImageId != null)
            {
                hashCode += ImageId.GetHashCode();
            }

            if (ItemData != null)
            {
                hashCode += ItemData.GetHashCode();
            }

            if (CategoryData != null)
            {
                hashCode += CategoryData.GetHashCode();
            }

            if (ItemVariationData != null)
            {
                hashCode += ItemVariationData.GetHashCode();
            }

            if (TaxData != null)
            {
                hashCode += TaxData.GetHashCode();
            }

            if (DiscountData != null)
            {
                hashCode += DiscountData.GetHashCode();
            }

            if (ModifierListData != null)
            {
                hashCode += ModifierListData.GetHashCode();
            }

            if (ModifierData != null)
            {
                hashCode += ModifierData.GetHashCode();
            }

            if (TimePeriodData != null)
            {
                hashCode += TimePeriodData.GetHashCode();
            }

            if (ProductSetData != null)
            {
                hashCode += ProductSetData.GetHashCode();
            }

            if (PricingRuleData != null)
            {
                hashCode += PricingRuleData.GetHashCode();
            }

            if (ImageData != null)
            {
                hashCode += ImageData.GetHashCode();
            }

            if (MeasurementUnitData != null)
            {
                hashCode += MeasurementUnitData.GetHashCode();
            }

            if (SubscriptionPlanData != null)
            {
                hashCode += SubscriptionPlanData.GetHashCode();
            }

            if (ItemOptionData != null)
            {
                hashCode += ItemOptionData.GetHashCode();
            }

            if (ItemOptionValueData != null)
            {
                hashCode += ItemOptionValueData.GetHashCode();
            }

            if (CustomAttributeDefinitionData != null)
            {
                hashCode += CustomAttributeDefinitionData.GetHashCode();
            }

            if (QuickAmountsSettingsData != null)
            {
                hashCode += QuickAmountsSettingsData.GetHashCode();
            }

            return(hashCode);
        }
 public SubscriptionMessage(string tag, DiscountData discount) : base(tag)
 {
     discountData = discount;
 }