public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.ManageOfferOp();

            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            var amount = new sdkxdr.Int64();

            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            var price = stellar_dotnet_sdk.Price.FromString(Price);

            op.Price = price.ToXdr();
            var offerId = new sdkxdr.Uint64();

            offerId.InnerValue = OfferId;
            op.OfferID         = offerId;

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant  = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.MANAGE_OFFER);
            body.ManageOfferOp = op;

            return(body);
        }
        public ActionResult Selling(Buying model)
        {
            if (ModelState.IsValid)
            {
                var newSelling = new Selling
                {
                    ArtifactId  = model.ArtifactId,
                    DateTime    = DateTime.Now,
                    UserId      = model.UserId,
                    CharacterId = int.Parse(Request.Form["CharacterId"])
                };
                var saleWorth   = int.Parse(Request.Form["SaleWorth"]);
                var characterId = int.Parse(Request.Form["CharacterId"]);
                var currentUser = model.UserId;

                var currentCharacter = db.Characters.FirstOrDefault(c => c.UserId == currentUser && c.Id == characterId);

                currentCharacter.GoldDime = currentCharacter.GoldDime + saleWorth;
                db.Characters.AddOrUpdate(currentCharacter);

                var selling = db.Buyings.Find(model.Id);

                if (selling != null)
                {
                    db.Buyings.Remove(selling);
                    db.SaveChanges();
                }

                return(RedirectToAction("Selling", "Page"));
            }
            return(View());
        }
Exemple #3
0
        public OperationResult Create(SellingViewModel input)
        {
            var result = new OperationResult();

            try
            {
                BizModel context = new BizModel();
                using (var transaction = context.Database.BeginTransaction())//Rollback
                {
                    var     sellCount         = input.Quantity;
                    var     procurementRepo   = new BizRepository <Procurement>(context);
                    var     sellingSourceRepo = new BizRepository <SellingSource>(context);
                    var     sellingRepo       = new BizRepository <Selling>(context);
                    Selling entity            = new Selling()
                    {
                        PartNo         = input.PartNo,
                        Quantity       = input.Quantity,
                        SalesJobNumber = input.SalesJobNumber,
                        SellingDay     = input.SellingDay,
                        UnitPrice      = input.UnitPrice
                    };
                    sellingRepo.Create(entity);
                    context.SaveChanges();
                    var products = procurementRepo.GetAll()
                                   .Where((x) => x.PartNo == input.PartNo).OrderBy((x) => x.PurchasingDay);
                    foreach (var p in products)
                    {
                        if (sellCount <= 0)
                        {
                            break;
                        }
                        else
                        {
                            if (p.InvetoryQuantity >= sellCount)
                            {
                                p.InvetoryQuantity = p.InvetoryQuantity - sellCount;
                                CreateSellingSource(sellingSourceRepo, entity.SellingId, p.ProcurementId, sellCount);
                                sellCount = 0;
                            }
                            else
                            {
                                sellCount = sellCount - p.InvetoryQuantity;
                                CreateSellingSource(sellingSourceRepo, entity.SellingId, p.ProcurementId, p.InvetoryQuantity);
                                p.InvetoryQuantity = 0;
                            }
                        }
                    }

                    context.SaveChanges();
                    result.IsSuccessful = true;
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                result.IsSuccessful = false;
                result.exception    = ex;
            }
            return(result);
        }
Exemple #4
0
    public void IsItWorthSellingOrOwning(int numberOfYears)
    {
        Selling s2 = new Selling();
        double  c  = s2.GetMoneyLeft(720000, 560500, 3);
        double  f  = s2.GetMoneyGainedOnSelling(c, 12, numberOfYears);

        Console.WriteLine("The money gained on Selling the property in " + numberOfYears + " years is " + f);
        double sellingbenefit = s2.moneygainedonselling;

        Owning o2 = new Owning();

        o2.LessSaleCost(720000, 4, 3);
        o2.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, numberOfYears);
        Console.WriteLine("The money gained on Owning the property in  " + numberOfYears + " years is " + o2.moneygainedonowning);
        double owningbenefit = o2.moneygainedonowning;

        if (sellingbenefit < owningbenefit)
        {
            Console.WriteLine("Hello Sandeep, Please own the property for benefit. Good Luck! ");
        }
        else
        {
            Console.WriteLine("Hello Sandeep, Please sell the property for benefit. Good Luck! ");
        }
    }
Exemple #5
0
        public Selling Save([FromBody] Selling selling)
        {
            using (var transaction = _repository.BeginTransaction())
            {
                if (selling.Id == 0)
                {
                    selling.OwnerId  = _branchContext.Branch.Id;
                    selling.BranchId = _branchContext.Branch.Id;
                    selling.AuthorId = _sessionContext.UserId;
                }

                ModelState.Clear();
                TryValidateModel(selling);
                ModelState.Validate();

                if (selling.Id > 0)
                {
                    _repository.Update(selling);
                }
                else
                {
                    _repository.Insert(selling);
                }

                transaction.Commit();
            }

            return(selling);
        }
Exemple #6
0
        private void bt_Sale_Click(object sender, RoutedEventArgs e)
        {
            New_sale _newsalewind = new New_sale();

            var _goods = dbSclad.Goods.Select(p => new
            {
                Id   = p.Id,
                Name = p.Name
            }).ToList();

            _newsalewind.cb_Good.ItemsSource = _goods;
            _newsalewind.ShowDialog();

            if (_newsalewind.DialogResult == false)
            {
                return;
            }

            Selling _newsale = new Selling();

            _newsale.Customer = _newsalewind.tb_Customer.ToString();
            _newsale.Date     = _newsalewind.Date.SelectedDate.Value;
            _newsale.Count    = Convert.ToInt32(_newsalewind.tb_Count.Text);
            _newsale.Cost     = Convert.ToInt32(_newsalewind.tb_Cost.Text);
            _newsale.Price    = Convert.ToInt32(_newsalewind.tb_Price.Text);


            //_newGood.Name = _viewAdd.tb_Name.Text;
            //  _newGood.Instock = Convert.ToInt32(_viewAdd.tb_Count.Text);
            //  dbSclad.Goods.Add(_newGood);
            dbSclad.SaveChanges();

            MessageBox.Show("Добавлена новая продажа");
        }
Exemple #7
0
        public async Task <Selling> UpdateSelling(Selling selling)
        {
            await using var ctx = new ContextManager(_optionsBuilder.Options);
            ctx.Selling.Update(selling);
            await ctx.SaveChangesAsync();

            return(selling);
        }
Exemple #8
0
        public async Task <int> AddSelling(Selling selling)
        {
            await _context.Sellings.AddAsync(selling);

            await _context.SaveChangesAsync();

            return(selling.SellingId);
        }
Exemple #9
0
 public List <Selling> Post([FromBody] Selling value)
 {
     service.Create(value);
     return(service
            .GetAll()
            .Where(x => x.Customer != null)
            .ToList());
 }
Exemple #10
0
 public async Task <IActionResult> DeleteSelling(Selling selling)
 {
     if (await BL.BL.Instance.GetSellingById(selling.Id) == null)
     {
         return(NotFound("Selling not Found"));
     }
     BL.BL.Instance.DeleteSelling(selling);
     return(Ok("Selling deleted"));
 }
Exemple #11
0
 public static SellingModel ToSellingModel(Selling selling)
 {
     return(new SellingModel
     {
         ClientName = selling.Client.Name,
         Cost = selling.Cost,
         Date = selling.Date,
         Id = selling.Id,
         ManagerName = selling.Manager.Name,
         ProductName = selling.Product.Name
     });
 }
Exemple #12
0
 public async Task <IActionResult> EditSelling(Selling selling)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.Values));
     }
     if (await BL.BL.Instance.GetSellingById(selling.Id) == null)
     {
         return(NotFound("Selling not Found"));
     }
     return(Ok(await BL.BL.Instance.UpdateSelling(selling)));
 }
Exemple #13
0
    public void IsItWorthSellingOrOwning()
    {
        Selling s = new Selling();
        double  a = s.GetMoneyLeft(720000, 560500, 3);
        double  d = s.GetMoneyGainedOnSelling(a, 12, 1);

        Console.WriteLine("The money gained on Selling the property in 1 year is " + d);


        Selling s1 = new Selling();
        double  b  = s1.GetMoneyLeft(720000, 560500, 3);
        double  e  = s1.GetMoneyGainedOnSelling(b, 12, 3);

        Console.WriteLine("The money gained on Selling the property in 3 years is " + e);

        Selling s2 = new Selling();
        double  c  = s2.GetMoneyLeft(720000, 560500, 3);
        double  f  = s2.GetMoneyGainedOnSelling(c, 12, 5);

        Console.WriteLine("The money gained on Selling the property in 5 years is " + f);
        double sellingbenefit = s2.moneygainedonselling;



        Owning o = new Owning();

        o.LessSaleCost(720000, 4, 3);
        o.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, 1);
        Console.WriteLine("The money gained on Owning the property in 1 year is " + o.moneygainedonowning);

        Owning o1 = new Owning();

        o1.LessSaleCost(720000, 4, 3);
        o1.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, 3);
        Console.WriteLine("The money gained on Owning the property in 3 years is " + o1.moneygainedonowning);

        Owning o2 = new Owning();

        o2.LessSaleCost(720000, 4, 3);
        o2.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, 5);
        Console.WriteLine("The money gained on Owning the property in 5 years is " + o2.moneygainedonowning);
        double owningbenefit = o2.moneygainedonowning;

        if (sellingbenefit < owningbenefit)
        {
            Console.WriteLine("Hello Sandeep, Please own the property for benefit. Good Luck! ");
        }
        else
        {
            Console.WriteLine("Hello Sandeep, Please sell the property for benefit. Good Luck! ");
        }
    }
Exemple #14
0
        public void AddNew(SellingModel sellingModel)
        {
            Selling selling = new Selling();
            var     manager = _unitOfWork.ManagerRepository.GetOne(x => x.Name == sellingModel.ManagerName);

            if (manager == null)
            {
                _unitOfWork.ManagerRepository.Add(new Manager()
                {
                    Name = sellingModel.ManagerName
                });
                var newManager = _unitOfWork.ManagerRepository.GetOne(x => x.Name == sellingModel.ManagerName);
                selling.ManagerId = newManager.Id;
            }
            else
            {
                selling.ManagerId = manager.Id;
            }
            var client = _unitOfWork.ClientRepository.GetOne(x => x.Name == sellingModel.ClientName);

            if (client == null)
            {
                _unitOfWork.ClientRepository.Add(new Client()
                {
                    Name = sellingModel.ClientName
                });
                var newClient = _unitOfWork.ClientRepository.GetOne(x => x.Name == sellingModel.ClientName);
                selling.ClientId = newClient.Id;
            }
            else
            {
                selling.ClientId = client.Id;
            }
            var product = _unitOfWork.ProductRepository.GetOne(x => x.Name == sellingModel.ProductName);

            if (product == null)
            {
                _unitOfWork.ProductRepository.Add(new Product()
                {
                    Name = sellingModel.ProductName
                });
                var newProduct = _unitOfWork.ProductRepository.GetOne(x => x.Name == sellingModel.ProductName);
                selling.ProductId = newProduct.Id;
            }
            else
            {
                selling.ProductId = product.Id;
            }
            selling.Date = sellingModel.Date;
            selling.Cost = sellingModel.Cost;
            _unitOfWork.SellingRepository.Add(selling);
        }
        /// <summary>
        /// 新增售房
        /// </summary>
        /// <returns></returns>
        public ActionResult AddSell(Sell sell, Selling selling, Transactions transactions)
        {
            int id = 0;
            int a  = bLL.SellsAdd(sell);

            //拿到  id
            if (a == 1)
            {
                id = bLL.Last()[0].SellID;
            }
            else
            {
                return(Content("<script>alert('该房屋已经上传');history.go(-1)</script>"));
            }

            int b = bLL.SellingAdd(selling, id);
            int c = bLL.TransactionsAdd(transactions, id);

            //添加商品图片
            if (Request.Files.Count > 0)
            {
                string[]      fileTypeStr = { "image/gif", "image/png", "image/jpeg", "image/jpg", "image/bmp" };
                List <string> strlist     = new List <string>();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    if (fileTypeStr.Contains(Request.Files[i].ContentType))
                    {
                        string fileName = Path.GetFileName(Request.Files[i].FileName);
                        strlist.Add(fileName);
                    }
                }
                if (bLL.AddSImg(id, strlist))
                {
                    //保存文件
                    //应用程序需要有服务器UploadFile文件夹的读写权限
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        Request.Files[i].SaveAs(Server.MapPath("~/Content/Selling/" + Request.Files[i].FileName));
                    }
                }
            }
            if (b == 1 && c == 1)
            {
                return(Content("<script>alert('添加成功');history.go(-1)</script>"));
            }
            else
            {
                return(Content("<script>alert('添加失败');history.go(-1)</script>"));
            }
        }
Exemple #16
0
        public async Task <IActionResult> AddSelling(Selling selling)
        {
            if (selling.Time.Day != DateTime.Now.Day)
            {
                selling.Time = DateTime.Now;
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values));
            }

            selling.Id ??= Guid.NewGuid();
            return(Ok(await BL.BL.Instance.AddSelling(selling)));
        }
Exemple #17
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.CreatePassiveOfferOp op = new sdkxdr.CreatePassiveOfferOp();
            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            sdkxdr.Int64 amount = new sdkxdr.Int64();
            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            Price price = Sdk.Price.FromString(Price);

            op.Price = price.ToXdr();

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();

            body.Discriminant =
                sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER);
            body.CreatePassiveOfferOp = op;

            return(body);
        }
Exemple #18
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.CreatePassiveSellOfferOp();

            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            var amount = new sdkxdr.Int64();

            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            var price = stellar_dotnet_sdk.Price.FromString(Price);

            op.Price = price.ToXdr();

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant             = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CREATE_PASSIVE_SELL_OFFER);
            body.CreatePassiveSellOfferOp = op;

            return(body);
        }
Exemple #19
0
        /// <summary>
        /// 修改订单
        /// </summary>
        /// <param name="sell"></param>
        /// <param name="selling"></param>
        /// <param name="sImg"></param>
        /// <param name="transactions"></param>
        /// <returns></returns>
        public ActionResult EditSELL(Sell sell, Selling selling, SImg sImg, Transactions transactions)
        {
            int a = sell.SellID;

            //添加商品图片
            if (Request.Files.Count > 0)
            {
                string[]      fileTypeStr = { "image/gif", "image/png", "image/jpeg", "image/jpg", "image/bmp" };
                List <string> strlist     = new List <string>();
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    if (fileTypeStr.Contains(Request.Files[i].ContentType))
                    {
                        string fileName = Path.GetFileName(Request.Files[i].FileName);
                        strlist.Add(fileName);
                    }
                }
                if (bll2.AddSImg(sell.SellID, strlist))
                {
                    //保存文件
                    //应用程序需要有服务器UploadFile文件夹的读写权限
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        Request.Files[i].SaveAs(Server.MapPath("~/Content/Selling/" + Request.Files[i].FileName));
                    }
                }
            }
            if (bLL.EditSELL(sell, selling, transactions))
            {
                return(RedirectToAction("EditSelling", "Sale", new { SellID = a }));
            }
            else
            {
                return(Content("<script>alert('修改失败');history.go(-1)</script>"));
            }
        }
Exemple #20
0
 public async Task <Selling> AddSelling(Selling selling)
 {
     return(await _sellingDao.AddSelling(selling));
 }
Exemple #21
0
        public void SetSystem(PlayerSystem player)
        {
            Owner = player;

            sellButton    = Instantiate(sellButton.gameObject, Owner.WorldCanvas.transform).GetComponent <Button>();
            upgradeButton = Instantiate(upgradeButton.gameObject, Owner.WorldCanvas.transform).GetComponent <Button>();

            Owner.InventoryUISystem.MoveItemToSpirit += OnMoveItemToSpirit;
            Owner.PlayerInputSystem.ClickedOnSpirit  += OnClickedOnSpirit;
            Owner.PlayerInputSystem.ClickedOnCell    += OnClickedOnCell;
            Owner.PlayerInputSystem.ClikedOnGround   += OnClickedOnGround;
            Owner.PlayerInputSystem.RMBPresed        += OnClickedOnGround;
            Owner.ItemDropSystem.ItemUICreated       += OnItemUICreated;

            sellButton.onClick.AddListener(OnSellButtonClick);
            upgradeButton.onClick.AddListener(OnUpgradeButtonClick);

            void OnUpgradeButtonClick()
            {
                Upgrading?.Invoke();
                UpdateUI();
            }

            void OnSellButtonClick()
            {
                Selling?.Invoke();
                ActivateUI(false);
            }

            void OnItemUICreated(ItemUISystem itemUI)
            {
                itemUI.DoubleClickedInSpiritInventory += OnItemDoubleClicked;
                itemUI.System.StatsApplied            += OnStatsApplied;

                void OnItemDoubleClicked(ItemUISystem _)
                {
                    if (itemUI.DraggedFrom == DraggedFrom.SpiritInventory)
                    {
                        RemoveItemFromSpirit();
                        MoveItemToPlayer?.Invoke(itemUI);
                    }

                    void RemoveItemFromSpirit()
                    {
                        if (itemUI.DraggedFrom == DraggedFrom.SpiritInventory)
                        {
                            allItemsUIInSpirits.Remove(itemUI);
                            isSlotEmpty[itemUI.SlotNumber] = true;
                            itemSlots[itemUI.SlotNumber].gameObject.SetActive(true);

                            ItemRemovedFromSpirit?.Invoke(new SpiritItemEventArgs(choosedSpirit, itemUI));
                            UpdateValues();
                        }
                    }
                }
            }

            void OnClickedOnSpirit(GameObject spirit) => ActivateUI(true);
            void OnClickedOnCell(GameObject spirit) => ActivateUI(false);
            void OnClickedOnGround() => ActivateUI(false);

            void OnMoveItemToSpirit(ItemUISystem itemUI)
            {
                var emptySlot = isSlotEmpty.IndexOf(true);

                if (emptySlot < 0)
                {
                    MoveItemToPlayer?.Invoke(itemUI);
                }
                else
                {
                    itemUI.transform.position = itemSlots[emptySlot].transform.position;
                    itemUI.transform.SetParent(itemSlots[emptySlot].transform.parent);

                    AddItemToSpirit(emptySlot);
                }

                void AddItemToSpirit(int slotNumber)
                {
                    allItemsUIInSpirits.Add(itemUI);
                    isSlotEmpty[slotNumber] = false;
                    itemSlots[slotNumber].gameObject.SetActive(false);

                    itemUI.DraggedFrom = DraggedFrom.SpiritInventory;
                    itemUI.SlotNumber  = slotNumber;

                    ItemAddedToSpirit?.Invoke(new SpiritItemEventArgs(choosedSpirit, itemUI));
                    UpdateItems();
                    UpdateValues();
                }
            }

            void ActivateUI(bool activate)
            {
                if (Owner.PlayerInputSystem.ChoosedSpirit == null)
                {
                    return;
                }

                UnsubscribeFromSpiritEvents();

                if (activate)
                {
                    baseAnimator.SetBool(isOpenBool, true);
                    choosedSpirit = Owner.PlayerInputSystem.ChoosedSpirit;

                    if (choosedSpirit.Owner == Owner)
                    {
                        sellButton.gameObject.SetActive(true);

                        sellButton.transform.position    = choosedSpirit.Prefab.transform.position + new Vector3(40, 30, 0);
                        upgradeButton.transform.position = choosedSpirit.Prefab.transform.position + new Vector3(40, 60, 30);
                    }

                    HideExpandedStatValues(true);
                    SubscribeToSpiritEvents();
                    UpdateUI();
                }
                else
                {
                    sellButton.gameObject.SetActive(false);
                    upgradeButton.gameObject.SetActive(false);

                    baseAnimator.SetBool(isOpenBool, false);
                    baseAnimator.SetBool(isExpandedBool, false);

                    UnsubscribeFromSpiritEvents();
                }

                void SubscribeToSpiritEvents()
                {
                    if (choosedSpirit == null)
                    {
                        return;
                    }

                    choosedSpirit.AbilityControlSystem.AbilityUsed += OnAbilityUsed;
                    choosedSpirit.EffectApplied += OnEffectApplied;
                    choosedSpirit.EffectRemoved += OnEffectRemoved;
                    choosedSpirit.StatsChanged  += OnStatsApplied;
                }

                void UnsubscribeFromSpiritEvents()
                {
                    if (choosedSpirit == null)
                    {
                        return;
                    }

                    choosedSpirit.AbilityControlSystem.AbilityUsed -= OnAbilityUsed;
                    choosedSpirit.EffectApplied -= OnEffectApplied;
                    choosedSpirit.EffectRemoved -= OnEffectRemoved;
                    choosedSpirit.StatsChanged  -= OnStatsApplied;
                }

                void OnEffectRemoved(Data.Effect effect)
                {
                    var appliedEffectUI = appliedEffectsUI.Find(effectUI => effectUI.EntityIndex == effect.Index);

                    if (appliedEffectUI != null)
                    {
                        appliedEffectUI.gameObject.SetActive(false);
                        appliedEffectsUI.Remove(appliedEffectUI);
                    }
                }

                void OnEffectApplied(Data.Effect effect)
                {
                    var poolObject      = appliedEffectsUIPool.PopObject();
                    var appliedEffectUI = poolObject.GetComponent <SlotWithCooldown>();

                    appliedEffectUI.Set(effect.Description, effect.Image, effect.Index);
                    appliedEffectsUI.Add(appliedEffectUI);
                }

                void OnAbilityUsed(AbilitySystem e)
                {
                    var slot = abilitySlots.Find(abilitySlot => abilitySlot.EntityIndex == e.Ability.Index);

                    slot.CooldownImage.fillAmount = 1f;

                    StartCoroutine(Cooldown());

                    IEnumerator Cooldown()
                    {
                        while (slot.CooldownImage.fillAmount > 0)
                        {
                            slot.CooldownImage.fillAmount -= 1 / e.Ability.Cooldown * Time.deltaTime * 2;
                            yield return(deltaTimeDelay);
                        }
                    }
                }
            }

            void UpdateUI()
            {
                choosedSpirit = Owner.PlayerInputSystem.ChoosedSpirit;

                UpdateItems();
                UpdateValues();
                UpdateSlotsWithCooldown(abilitySlots, choosedSpirit.Data.Abilities);
                UpdateSlotsWithCooldown(traitSlots, choosedSpirit.Data.Traits);

                void UpdateSlotsWithCooldown <T>(List <SlotWithCooldown> slots, List <T> slotEntities) where T : Entity
                {
                    slots.ForEach(slot => slot.gameObject.SetActive(false));

                    for (int i = 0; i < slotEntities.Count; i++)
                    {
                        slots[i].Set(slotEntities[i].Description, slotEntities[i].Image, slotEntities[i].Index);
                    }
                }
            }

            void UpdateItems()
            {
                var choosedSpiritItems = choosedSpirit.Data.Inventory.Items;
                var maxSlots           = choosedSpirit.Data.Get(Enums.Spirit.MaxInventorySlots).Value;

                isSlotEmpty.Clear();
                allItemsUIInSpirits.ForEach(item => item.gameObject.SetActive(false));

                UpdateSlotsAmount();

                choosedSpiritItems.ForEach(itemInInventory =>
                {
                    var itemFromDroppedItems = allItemsUIInSpirits.Find(droppedItem => itemInInventory.Index == droppedItem.System.Index);

                    if (itemFromDroppedItems != null)
                    {
                        itemFromDroppedItems.gameObject.SetActive(true);
                        isSlotEmpty[itemFromDroppedItems.SlotNumber] = false;
                    }
                });

                void UpdateSlotsAmount()
                {
                    for (int i = 0; i < itemSlots.Count; i++)
                    {
                        var isInSlotLimit = i < maxSlots;

                        itemSlots[i].gameObject.SetActive(isInSlotLimit);
                        isSlotEmpty.Add(isInSlotLimit);
                    }
                }
            }

            void OnStatsApplied() => UpdateValues();

            void UpdateValues()
            {
                var spirit = choosedSpirit.Data;

                spiritName.text = spirit.Name;
                image.sprite    = spirit.Image;

                SetExpBarValue();
                SetStatValues();

                void SetExpBarValue()
                {
                    var neededExp   = (float)ReferenceHolder.ExpToLevelUp[(int)spirit.Get(Numeral.Level).Value];
                    var currentExp  = (float)spirit.Get(Numeral.Exp).Value;
                    var expBarValue = 1 / (neededExp / currentExp);

                    expBar.fillAmount = expBarValue;
                }

                void SetStatValues()
                {
                    numeralStatValuesUI.ForEach(statUI => statUI.Value.text = statUI.NumeralValue.AttributeToString());
                    spiritStatValuesUI.ForEach(statUI => statUI.Value.text  = statUI.SpiritValue.AttributeToString());
                }
            }
        }
Exemple #22
0
        protected override void Seed(DiscContext context)
        {
            try
            {
                context.Bands.AddRange(
                    new List <Band>

                {
                    new Band {
                        Name = "Сборники"
                    },
                    new Band {
                        Name = "Виа Гра", Year = 2002
                    },
                    new Band {
                        Name = "Ария", Year = 1984
                    },
                    new Band {
                        Name = "Меладзе", Year = 1995
                    },
                    new Band {
                        Name = "Тальков", Year = 1984
                    },
                    new Band {
                        Name = "Наутилус", Year = 1983
                    },
                });
                context.Formats.AddRange(
                    new List <Format>
                {
                    new Format {
                        Name = "audio"
                    },
                    new Format {
                        Name = "mp3"
                    }
                });
                context.Sellers.AddRange(
                    new List <Seller>
                {
                    new Seller {
                        Name = "Федоров Максим"
                    },
                    new Seller {
                        Name = "Орлов Александр"
                    }
                });
                context.SaveChanges();
                Seller seller1 = context.Sellers.FirstOrDefault(s => s.Id == 1);
                Seller seller2 = context.Sellers.FirstOrDefault(s => s.Id == 2);
                context.CDs.AddRange(
                    new List <CD>
                {
                    new CD {
                        Name = "Союз 28", Cd_Date = 2004, Band = context.Bands.FirstOrDefault(b => b.Id == 1), Format = context.Formats.FirstOrDefault(f => f.Id == 1)
                    },
                    new CD {
                        Name = "Стоп Снято", Cd_Date = 2002, Band = context.Bands.FirstOrDefault(b => b.Id == 2), Format = context.Formats.FirstOrDefault(f => f.Id == 1)
                    },
                    new CD {
                        Name = "Крещенье Огнем", Cd_Date = 2003, Band = context.Bands.FirstOrDefault(b => b.Id == 3), Format = context.Formats.FirstOrDefault(f => f.Id == 1)
                    },
                    new CD {
                        Name = "Все альбомы", Cd_Date = 2005, Band = context.Bands.FirstOrDefault(b => b.Id == 4), Format = context.Formats.FirstOrDefault(f => f.Id == 2)
                    },
                    new CD {
                        Name = "Все альбомы", Cd_Date = 2005, Band = context.Bands.FirstOrDefault(b => b.Id == 5), Format = context.Formats.FirstOrDefault(f => f.Id == 2)
                    },
                    new CD {
                        Name = "Лучшие песни", Cd_Date = 2005, Band = context.Bands.FirstOrDefault(b => b.Id == 3), Format = context.Formats.FirstOrDefault(f => f.Id == 2)
                    },
                    new CD {
                        Name = "Атлантида", Cd_Date = 1997, Band = context.Bands.FirstOrDefault(b => b.Id == 6), Format = context.Formats.FirstOrDefault(f => f.Id == 2)
                    },
                    new CD {
                        Name = "Атлантида", Cd_Date = 1997, Band = context.Bands.FirstOrDefault(b => b.Id == 6), Format = context.Formats.FirstOrDefault(f => f.Id == 1)
                    },
                    new CD {
                        Name = "Крылья", Cd_Date = 1997, Band = context.Bands.FirstOrDefault(b => b.Id == 6), Format = context.Formats.FirstOrDefault(f => f.Id == 1)
                    },
                });
                context.SaveChanges();
                CD cD = context.CDs.FirstOrDefault(f => f.Name == "Союз 28");
                context.Sellings.AddRange(
                    new List <Selling>
                {
                    new Selling {
                        Seller = seller1, CD = cD
                    },
                    new Selling {
                        Seller = seller1, CD = context.CDs.FirstOrDefault(f => f.Id == 2)
                    },
                    new Selling {
                        Seller = seller1, CD = context.CDs.FirstOrDefault(f => f.Id == 3)
                    },
                    new Selling {
                        Seller = seller1, CD = context.CDs.FirstOrDefault(f => f.Id == 4)
                    },
                    new Selling {
                        Seller = seller1, CD = context.CDs.FirstOrDefault(f => f.Id == 5)
                    },
                    new Selling {
                        Seller = seller2, CD = context.CDs.FirstOrDefault(f => f.Id == 6)
                    },
                    new Selling {
                        Seller = seller2, CD = context.CDs.FirstOrDefault(f => f.Id == 1)
                    },
                    new Selling {
                        Seller = seller2, CD = context.CDs.FirstOrDefault(f => f.Id == 7)
                    },
                    new Selling {
                        Seller = seller1, CD = context.CDs.FirstOrDefault(f => f.Id == 8)
                    },
                    new Selling {
                        Seller = seller2, CD = context.CDs.FirstOrDefault(f => f.Id == 9)
                    },
                });


                //            select B.Name, Sel.Name
                //from dbo.Bands B
                //join dbo.CDs C on C.Band_Id = B.Id
                //Join dbo.Sellings S on S.Cd_Id = C.Id
                //join dbo.Sellers Sel on Sel.Id = S.Seller_Id
                context.SaveChanges();
                Selling selling = context.Sellings.ToList()[0];
                base.Seed(context);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #23
0
 public async void DeleteSelling(Selling selling)
 {
     await using var ctx = new ContextManager(_optionsBuilder.Options);
     ctx.Selling.Remove(selling);
     await ctx.SaveChangesAsync();
 }
Exemple #24
0
        public Selling Sell([FromBody] Selling selling)
        {
            using (var transaction = _repository.BeginTransaction())
            {
                if (selling.Id == 0)
                {
                    throw new PawnshopApplicationException("Сохраните реализацию для регистрации продажи");
                }

                if (selling.CashOrderId.HasValue)
                {
                    throw new PawnshopApplicationException("Продажа уже зарегистрирована");
                }

                selling.Status = SellingStatus.Sold;

                if (selling.ContractId.HasValue && selling.ContractPositionId.HasValue)
                {
                    var contract = _contractRepository.Get(selling.ContractId.Value);
                    var position = contract.Positions.SingleOrDefault(p => p.Id == selling.ContractPositionId.Value);
                    if (position != null)
                    {
                        position.Status = ContractPositionStatus.Disposed;
                    }
                    if (contract.Positions.All(p => p.Status == ContractPositionStatus.Disposed))
                    {
                        contract.Status = ContractStatus.Disposed;
                    }
                    _contractRepository.Update(contract);
                }

                ModelState.Clear();
                TryValidateModel(selling);
                ModelState.Validate();

                var settings = _branchContext.Configuration.CashOrderSettings
                               .Get(selling.CollateralType).DisposeSettings;

                if (!selling.SellingDate.HasValue)
                {
                    throw new PawnshopApplicationException("Поле дата продажи обязательно для заполнения");
                }

                if (!selling.SellingCost.HasValue)
                {
                    throw new PawnshopApplicationException("Поле стоимость продажи обязательно для заполнения");
                }

                if (!settings.DebitId.HasValue)
                {
                    throw new PawnshopApplicationException("В настройках организации заполните счет дебет для реализации");
                }

                if (!settings.CreditId.HasValue)
                {
                    throw new PawnshopApplicationException("В настройках организации заполните счет кредит для реализации");
                }

                var cashOrder = new CashOrder
                {
                    OrderType   = OrderType.CashIn,
                    OrderNumber = _counterRepository.Next(
                        OrderType.CashIn, selling.SellingDate.Value.Year,
                        _branchContext.Branch.Id,
                        _branchContext.Configuration.CashOrderSettings.CashInNumberCode),
                    OrderDate       = selling.SellingDate.Value,
                    OrderCost       = selling.SellingCost.Value,
                    DebitAccountId  = settings.DebitId.Value,
                    CreditAccountId = settings.CreditId.Value,
                    UserId          = _sessionContext.UserId,
                    Reason          = $"Продажа изделия {selling.Note}",
                    RegDate         = DateTime.Now,
                    OwnerId         = _branchContext.Branch.Id,
                    BranchId        = _branchContext.Branch.Id,
                    AuthorId        = _sessionContext.UserId
                };

                _cashOrderRepository.Insert(cashOrder);
                selling.CashOrderId = cashOrder.Id;
                selling.CashOrder   = _cashOrderRepository.Get(cashOrder.Id);

                _repository.Update(selling);

                transaction.Commit();
            }

            return(selling);
        }
Exemple #25
0
 /// <summary>
 /// 添加卖点信息
 /// </summary>
 /// <param name="selling"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public int SellingAdd(Selling selling, int id)
 {
     selling.SellID = id;
     return(dal.SellingAdd(selling));
 }
Exemple #26
0
 /// <summary>
 /// 修改售房信息
 /// </summary>
 /// <param name="sell"></param>
 /// <param name="selling"></param>
 /// <param name="transactions"></param>
 /// <param name="sImg"></param>
 /// <returns></returns>
 public bool EditSELL(Sell sell, Selling selling, Transactions transactions)
 {
     return(dal.EditSELL(sell, selling, transactions));
 }
Exemple #27
0
 public void DeleteSelling(Selling selling)
 {
     _sellingDao.DeleteSelling(selling);
 }
Exemple #28
0
 public Task RemoveSelling(Selling selling)
 {
     _context.Sellings.Remove(selling);
     return(_context.SaveChangesAsync());
 }
Exemple #29
0
 public void Put(Selling value)
 {
     service.Create(value);
 }
Exemple #30
0
 public async Task <Selling> UpdateSelling(Selling selling)
 {
     return(await _sellingDao.UpdateSelling(selling));
 }