public async Task <IActionResult> Create([Bind("Id,Nume,Parola,Creare,Email,Telefon")] Utilizatori utilizatori) { if (ModelState.IsValid) { _context.Add(utilizatori); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(utilizatori)); }
public async Task <IActionResult> Create(Produs produs) { if (ModelState.IsValid) { _context.Add(produs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(produs)); }
public async Task <IActionResult> CumparaAsync(int id) { var user = _context.Utilizatori.FirstOrDefault(x => x.Nume == Request.Cookies["LoggedUser"]); var cos = new Cos(); if (user == null) { return(RedirectToAction("Login", "Home")); } else { cos = _context.Cos.FirstOrDefault(e => e.Status == "Draft" && e.UserId == user.Id); } if (cos == null) { cos = new Cos(); cos.Status = "Draft"; cos.UserId = user.Id; cos.Creare = DateTime.Now; _context.Add(cos); await _context.SaveChangesAsync(); } var cosElemente = new CosElemente { Cantitate = 1, ProdusId = id, CosId = cos.Id }; _context.Add(cosElemente); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }