public async Task <IActionResult> Create(CreateWebsiteViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var website = new Website { Domain = model.Domain, Description = model.Description, CreatedAt = model.CreatedAt, User = await GetCurrentUser() }; _context.Add(website); await _context.SaveChangesAsync(); if (User.IsInRole("Admin")) { return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction(nameof(UserWebsites))); } }
public async Task <IActionResult> Create(CreateOrderViewModel model) { if (!ModelState.IsValid) { model.Websites = _context.Websites; return(View(model)); } var order = new Order { Price = model.Price, Description = model.Description, Status = model.Status, Website = await _context.Websites.SingleOrDefaultAsync(c => c.WebsiteId == model.WebsiteId) }; _context.Add(order); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }