Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,Name,Units")] PartType partType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(partType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(partType));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,Address")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stock);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            PopulatePositionsData(stock);
            return(View(stock));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ID,PartID,StockID,ArrDate,Quantity")] Left left)
        {
            if (ModelState.IsValid)
            {
                _context.Add(left);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartID"]  = new SelectList(_context.Parts, "ID", "ID", left.PartID);
            ViewData["StockID"] = new SelectList(_context.Stocks, "ID", "ID", left.StockID);
            return(View(left));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("CustomerID,SignDate")] Contract contract)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contract);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["CustomerID"] = new SelectList(_context.Customers, "ID", "ID", contract.CustomerID);
            PopulateCustomersDropDownList();
            return(View(contract));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("FirstName,Surname")] Employee employee)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(employee);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Виникла помилка під час збереження даних. " + ex.Message);
            }
            return(View(employee));
        }