예제 #1
0
        public async Task <IActionResult> Create([Bind("UserId,Username,Password,Nume,Prenume,Email,PhoneNumber")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("AnnounceId,Title,Description,AddingDate,ExpiringDate,CategoryId,UserId,Poza,NumeleCategoriei,to64")] Announce announce)
        {
            if (ModelState.IsValid)
            {
                announce.AddingDate   = DateTime.Now;
                announce.ExpiringDate = DateTime.Now.AddDays(10);
                _context.Add(announce);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryName", announce.CategoryId);
            ViewData["UserId"]     = new SelectList(_context.User, "UserId", "Email", announce.UserId);
            return(View(announce));
        }