Exemplo n.º 1
0
        public async Task <IActionResult> Create(Attendee attendee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(attendee);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(attendee));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new request
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <Request> Create(Request request, IFormFile file)
        {
            if (!Validate(request))
            {
                throw new Exception("Failed to create a request");
            }

            request.FilePath = _fileService.CreateFile(file);
            _context.Add(request);

            await _context.SaveChangesAsync();

            return(request);
        }
Exemplo n.º 4
0
        public async Task <Product> Create(Product product, IFormFile file)
        {
            if (!Validate(product))
            {
                throw new Exception("Failed to create the prodcut");
            }

            product.ProductImage.Add(new ProductImage
            {
                FilePath = _fileService.CreateFile(file)
            });

            _context.Add(product);

            await _context.SaveChangesAsync();

            return(product);
        }