public ActionResult Add(CarVM model)
 {
     if (model.Type == "N" && model.Mileage > 1000)
     {
         ModelState.AddModelError("Mileage", "Mileage of new vehicle must be between 0 and 1000");
     }
     if (ModelState.IsValid)
     {
         var tmp = _repo.AddCar(model);
         if (tmp.Result.Success)
         {
             return(RedirectToAction("List"));
         }
         else
         {
             ModelState.AddModelError("Vehicle", "Cannot add vehicle");
         }
     }
     model.SetMakeItems(_repo.GetMakeList());
     model.SetBodyStyleItems();
     model.SetColorItems();
     model.SetInteriorItems();
     model.SetTransmissionItems();
     model.SetTypeItems();
     return(View(model));
 }
Example #2
0
        public ActionResult CreateCar([FromBody] NewCarRequest carRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model state not valid"));
            }
            var model = new Car
            {
                Title    = carRequest.Title,
                Name     = carRequest.Name,
                Power    = carRequest.Power,
                Price    = carRequest.Price,
                DateMade = carRequest.DateMade,
                Mileage  = carRequest.Mileage,
            };

            _carService.AddCar(model);
            return(Ok($"Car created: {model.Name}"));
        }
Example #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"));
        }
Example #4
0
 public ExecResult AddCar(CarModel model)
 {
     return(_car.AddCar(model));
 }