Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Title,Artist,Album,ReleaseYear,Genre,Filename,Folder")] Music music)
        {
            if (ModelState.IsValid)
            {
                _context.Add(music);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(music));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("DeliveryId,Date,Status")] Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                _context.Add(delivery);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(delivery));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("PersonId,Name,Mail,Age")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
        public async Task <IActionResult> Create([Bind("CustomerId,Name,address,address2,address3,zipcode,city")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price,Rating")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("ProductId,Description,Price")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("InvoiceId,CustomerId,Ref,CreationDate,StartPeriod,EndPeriod,Status")] Invoice invoice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(invoice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "CustomerId", "Name", invoice.CustomerId);
            return(View(invoice));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("FirstName, LastName, DepartmentId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                employee.Department = _context.Departments.Find(employee.DepartmentId);
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.DepartmentId = new SelectList(_context.Departments, nameof(Department.Id), nameof(Department.Name));
            return(View(employee));
        }
        public async Task <IActionResult> Create([Bind("InvoiceLineId,InvoiceId,ProductId,CreationDate,Description,Quantity,Price")] InvoiceLine invoiceLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(invoiceLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InvoiceId"] = new SelectList(_context.Set <Invoice>(), "InvoiceId", "InvoiceId", invoiceLine.InvoiceId);
            ViewData["ProductId"] = new SelectList(_context.Set <Product>(), "ProductId", "ProductId", invoiceLine.ProductId);
            return(View(invoiceLine));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("BarcodeId,CustomerId,ProductId")] Barcode barcode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(barcode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "CustomerId", "Name", barcode.CustomerId);
            ViewData["ProductId"]  = new SelectList(_context.Set <Product>(), "ProductId", "Description", barcode.ProductId);
            return(View(barcode));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("Id, Name")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View(department));
            }
        }