Exemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            int customerID = await customer.AddCustomer(new Customer()
            {
                Adress  = cars.CustomerAdress,
                IdPhoto = await Uplode(cars.CustomerIdPhoto, "Customers"),
                Name    = cars.CustomerName,
                Phone   = cars.CustomerPhone
            });

            int incomeID = await income.AddIncome(new Income()
            {
                Price = cars.PriceIncome
            });

            if (cars.CheckAmount.Count > 0)
            {
                for (int i = 0; i < cars.CheckAmount.Count; i++)
                {
                    check.AddCheck(new Check()
                    {
                        Amount   = cars.CheckAmount[i],
                        DueDate  = cars.DueDate[i],
                        IncomeId = incomeID,
                        Name     = cars.CheckOwner[i],
                        Photo    = await Uplode(cars.CheckPhoto[i], "Check")
                    });
                }
            }
            await cash.AddCashAsync(new Cash()
            {
                Amount   = cars.cashTaken,
                IncomeId = incomeID,
                Arrested = true
            });


            int saleID = await _sale.Addsale(new Sale()
            {
                CarId      = cars.carID,
                Commission = 0,
                CustomerId = customerID,
                Date       = DateTime.Today,
            });

            var x = car[cars.carID];

            x.Sold = true;
            await car.UpdateCarAsync(x);

            await sellrecord.AddsellRecords(new SellRecords()
            {
                IncomeId = incomeID,
                SaleId   = saleID
            });

            callproc cc = new callproc();

            cc.updateCapitalShare(this.User.FindFirst(ClaimTypes.NameIdentifier).Value);
            cc = null;

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public IActionResult OnPost()
        {
            var x = HttpContext.Session.GetString("state");

            int.TryParse(HttpContext.Session.GetString("recordID"), out recordID);
            int.TryParse(HttpContext.Session.GetString("CarID"), out carID);


            if (x != string.Empty && recordID != 0 && carID != 0)
            {
                if (HttpContext.Session.GetString("state") == "True" && int.TryParse(HttpContext.Session.GetString("recordID"), out recordID))
                {
                    afterSellExpncess.AddAfterSellExpncess(new AfterSellExpncess()
                    {
                        Amount = input.Amount, Date = DateTime.Today, Description = input.Description, RecordId = recordID
                    });

                    output = afterSellExpncess.GetallSellExpncesses.Where(a => a.RecordId == recordID).Select(a => new inputmodel()
                    {
                        Amount = a.Amount, Date = a.Date, Description = a.Description, RecordId = a.RecordId
                    }).ToList();

                    var IncodeID  = sellrecord[recordID].IncomeId;
                    var incomeObj = income[IncodeID.Value];
                    incomeObj.Price -= input.Amount;
                    income.UpdateIncome(IncodeID.Value, incomeObj);

                    cash.AddCashAsync(new Cash()
                    {
                        Amount = input.Amount, Arrested = true, DateArrested = DateTime.Today, IncomeId = IncodeID
                    });

                    ModelState.Clear();

                    callproc cc = new callproc();
                    cc.updateCapitalShare(this.User.FindFirst(ClaimTypes.NameIdentifier).Value);
                    cc = null;



                    return(Redirect("/mantain?id=" + sellrecord[recordID].Sale.CarId + "&x=" + HttpContext.Session.GetString("state")));
                }
                else
                {
                    afterBuyExpncess.AddAfterBuyExpncessAsync(new AfterBuyExpencess()
                    {
                        Amount = input.Amount, Date = DateTime.Today, Description = input.Description, RecordId = recordID
                    });
                    output = afterBuyExpncess.GetAfterBuyExpncesses.Where(a => a.RecordId == recordID).Select(a => new inputmodel()
                    {
                        Amount = a.Amount, Date = a.Date, Description = a.Description, RecordId = a.RecordId
                    }).ToList();
                    var outcomeID = buyRecords[recordID].OutcomeId;
                    var oucomeObj = outcome[outcomeID];
                    oucomeObj.Price += input.Amount;
                    outcome.UpdateOutcome(outcomeID, oucomeObj);

                    cash.AddCashAsync(new Cash()
                    {
                        Amount = input.Amount, Arrested = true, DateArrested = DateTime.Today, OutcomeId = outcomeID
                    });

                    ModelState.Clear();
                    //this code to update capital share using proc
                    //callproc cc = new callproc();
                    //cc.updateCapitalShare(this.User.FindFirst(ClaimTypes.NameIdentifier).Value);
                    //cc = null;
                    return(Redirect("/mantain?id=" + buyRecords[recordID].Buy.CarId + "&x=" + HttpContext.Session.GetString("state")));
                }
            }
            return(Page());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            {
                var car = new Car()
                {
                    Id          = 0,
                    CarId       = bUYACAR.CarID,
                    Insurance   = bUYACAR.Insurance.Value,
                    ModelId     = bUYACAR.ModelId,
                    MoreDetails = bUYACAR.moreDetails,
                    Owener      = bUYACAR.CarOwener,
                };
                var salePerson = new SalePerson()
                {
                    Adress   = bUYACAR.SaleAdress,
                    Name     = bUYACAR.SaleName,
                    Phone    = bUYACAR.SalePhone,
                    Idnumber = bUYACAR.IDNumber,
                    IdPhoto  = await Uplode(bUYACAR.IdPhoto, "ID")
                };
                var outcome = new Outcome()
                {
                    Price = bUYACAR.PriceOutcome
                };
                int OutcomeId = _outcome.AddOutcome(outcome).Result;


                var buy = new Buy()
                {
                    Date       = DateTime.Today,
                    CarId      = await _car.AddCar(car),
                    CustomerId = await _saleperson.AddSalePerson(salePerson),
                };
                var buyrecords = new BuyRecords()
                {
                    BuyId     = _buy.AddBuy(buy).Result,
                    OutcomeId = OutcomeId,
                    PartnerId = 1
                };
                await _buyrecord.AddBuyRecords(buyrecords);

                List <cc> dd = JsonConvert.DeserializeObject <List <cc> >(System.IO.File.ReadAllText("C:\\Users\\wwwmu\\source\\repos\\ManegmentSystems\\ManegmentSystems\\wwwroot\\data.json"));

                await _cash.AddCashAsync(new Cash()
                {
                    Amount       = bUYACAR.CashAmount[0],
                    Arrested     = true,
                    OutcomeId    = OutcomeId,
                    IncomeId     = null,
                    DateArrested = DateTime.Today
                });

                for (int i = 1; i < bUYACAR.CashAmount.Count - 1; i++)

                {
                    await _cash.AddCashAsync(new Cash()
                    {
                        Amount    = bUYACAR.CashAmount[i],
                        Arrested  = false,
                        OutcomeId = OutcomeId,
                        IncomeId  = null
                    });
                }
                for (int i = 0; i < dd.Count; i++)

                {
                    if (_check[dd[i].Id] == null)
                    {
                        _check.AddCheck(new Check()
                        {
                            Amount    = dd[i].Amount,
                            OutcomeId = OutcomeId,
                            Name      = dd[i].Name,
                            DueDate   = DateTime.Parse(dd[i].DueDate),
                            IncomeId  = null,

                            Photo = dd[i].files
                        });
                    }
                    else
                    {
                        var m = _check[dd[i].Id];
                        m.OutcomeId = OutcomeId;
                        await _check.UpdateCheck(dd[i].Id, m);
                    }
                }
            }
            callproc cc = new callproc();

            cc.updateCapitalShare(this.User.FindFirst(ClaimTypes.NameIdentifier).Value);
            cc = null;

            return(RedirectToPage("/gallary"));
        }