Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Price,Quantity")] Phone phone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phone);
                await _context.SaveChangesAsync();

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(memory));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("PhoneId,OrderId")] PhoneOrder phoneOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phoneOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"] = new SelectList(_context.Order, "Id", "Id", phoneOrder.OrderId);
            ViewData["PhoneId"] = new SelectList(_context.Phone, "Id", "Id", phoneOrder.PhoneId);
            return(View(phoneOrder));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Title,Body,SentBy,Posted,IP,PhoneId")] Comment comment, int PhoneId)
        {
            if (ModelState.IsValid)
            {
                comment.IP     = HttpContext.Connection.RemoteIpAddress.ToString();
                comment.Posted = DateTime.Now;
                comment.Phone  = _context.Phone.First(p => p.Id == PhoneId);

                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(comment));
        }