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)); }
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)); }
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)); }
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)); }