Пример #1
0
        // GET: SalesController/Create
        public ActionResult Create()
        {
            CreateSale createSale = new CreateSale();

            createSale.CarList = _carService.All().CarList;

            return(View(createSale));
        }
Пример #2
0
        public Sale Add(CreateSale createSale)
        {
            Sale sale = new Sale();

            sale.BuyerName     = createSale.BuyerName;
            sale.SellerName    = createSale.SellerName;
            sale.TimeOfSale    = DateTime.Now;
            sale.CarInQuestion = _carRepo.Read(createSale.CarInQuestionId);

            return(_saleRepo.Create(sale));
        }
Пример #3
0
 public ActionResult Create(CreateSale createSale)
 {
     if (ModelState.IsValid)
     {
         _saleService.Add(createSale);
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(View(createSale));
     }
 }
Пример #4
0
        public Sale Edit(int id, CreateSale sale)
        {
            Sale saleToUpdate = FindById(id);

            if (saleToUpdate == null)
            {
                return(null);
            }

            saleToUpdate.BuyerName       = sale.BuyerName;
            saleToUpdate.SellerName      = sale.SellerName;
            saleToUpdate.CarInQuestionId = sale.CarInQuestionId;

            return(_saleRepo.Update(saleToUpdate));
        }
Пример #5
0
 // POST: api/Sale
 public void Post([FromBody] CreateSale create)
 {
     manager.Add(create);
 }