示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Price,MeetingLocationX,MeetingLocationY")] Sale sale)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sale);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sale));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,UserName,EMail,Password,IsAdmin")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,Name")] FieldOfStudy fieldOfStudy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fieldOfStudy);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fieldOfStudy));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] AcademicInstitute academicInstitute)
        {
            if (ModelState.IsValid)
            {
                _context.Add(academicInstitute);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(academicInstitute));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Description,FieldOfStudyId,AcademicInstituteId,Address")] Project project)
        {
            int userId = ClaimsExtension.GetUserId(HttpContext);

            // No user id redirect to login
            if (userId < 0)
            {
                return(RedirectToAction("Login", "Account"));
            }

            project.OwnerId = userId;
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
 public async Task <IActionResult> Create([Bind("UserName,Password,EMail,FirstName,LastName")] RegistrationDetails regDetails, string returnUrl)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var user = Register(regDetails);
             _context.Add(user);
             await _context.SaveChangesAsync();
         }
         return(View("Login"));
     }
     catch
     {
         return(View("Login"));
     }
 }