示例#1
0
        public ActionResult CreateEditAddOn([System.Web.Http.FromBody] AddOns Addons)
        {
            Addons.AddonnList = Addons.AddonnList.FindAll(x => x.AddOnTitle != null && x.AddOnTitle != "");
            if (Addons.IsServingAddon && Addons.AddOnCatorItmId == 0)
            {
                Addons.OrgID = OrderType.CurrOrgId();
                //store in global list item not created
                AddOns.ServingAddonList.RemoveAll(x => x.OrgID == Addons.OrgID);
                AddOns.ServingAddonList.Add(Addons);
            }
            else
            {
                foreach (var AddOn in Addons.AddonnList)
                {
                    AddOn.CatOrItmId = Addons.AddOnCatorItmId;
                    AddOn.Save();
                    foreach (var AddOnItem in AddOn.AddOnItemList)
                    {
                        if (AddOn.DeletedStatus == 1)
                        {
                            AddOnItem.DelStatus = 1;
                        }
                        AddOnItem.AddonID = AddOn.TitleId;
                        double taxAmt = (AddOnItem.CostPrice * AddOnItem.Tax) / 100;
                        AddOnItem.Price      = AddOnItem.CostPrice + taxAmt;
                        AddOnItem.CatOrItmId = Addons.AddOnCatorItmId;
                        AddOnItem.Save();
                    }
                }
            }

            return(Json(new { data = "" }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public async Task <Response <List <AddOnItem> > > GetAllAddOns()
        {
            if (IsStoreContextTypePresent)
            {
                StoreContext storeContext             = StoreContext.GetDefault();
                Response <List <AddOnItem> > response = new Response <List <AddOnItem> >();
                string[] productKinds = { "Durable", "Consumable", "UnmanagedConsumable" };
                StoreProductQueryResult queryResult = await storeContext.GetAssociatedStoreProductsAsync(productKinds);

                if (queryResult.ExtendedError != null)
                {
                    response.IsError = true;
                    response.Message = queryResult.ExtendedError.Message;
                    response.Error   = queryResult.ExtendedError;
                }
                else
                {
                    List <AddOnItem> ret = new List <AddOnItem>();
                    IReadOnlyDictionary <string, StoreLicense> licenses = await GetAddOnLicenses();

                    foreach (KeyValuePair <string, StoreProduct> item in queryResult.Products)
                    {
                        AddOnItem    addOn        = new AddOnItem(item.Value);
                        var          matchingPair = licenses.FirstOrDefault(p => p.Key.StartsWith(item.Key));
                        StoreLicense license      = matchingPair.Value;
                        addOn.IsActive   = license?.IsActive ?? false;
                        addOn.ExpiryDate = license?.ExpirationDate ?? default(DateTimeOffset);
                        ret.Add(addOn);
                    }
                    response.Content = ret;
                }
                return(response);
            }
            else
            {
                return(new Response <List <AddOnItem> >());
            }
        }