예제 #1
0
 public async Task<IActionResult> Create([Bind("ReportID,Content,Hours,Approved,DateCreated,Id,CodeId")] Report report)
 {
     if (ModelState.IsValid)
     {
         _context.Add(report);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     ViewData["CodeId"] = new SelectList(_context.Set<ClassificationCode>(), "CodeId", "CodeId", report.CodeId);
     return View(report);
 }
예제 #2
0
        public async Task <IActionResult> Create([Bind("FirstName,LastName,MemberStatus,SkipperStatus,Street,City,Province,PostalCode,Country,MobilePhone,HomePhone,WorkPhone,SailingQualifications,Skills,SailingExperience,Credits,EmergencyContactId,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmergencyContactId"] = new SelectList(_context.EmergencyContacts, "EmergencyContactId", "EmergencyContactId", user.EmergencyContactId);
            return(View(user));
        }
예제 #3
0
        public async Task <IActionResult> Create(DocumentViewModel dvm)
        {
            Document document = new Document();

            if (ModelState.IsValid)
            {
                var userManager = _services.GetRequiredService <UserManager <User> >();
                document.User = userManager.GetUserAsync(HttpContext.User).Result;

                using (var memoryStream = new MemoryStream()) {
                    document.ContentType  = dvm.Content.ContentType;
                    document.DocumentName = dvm.Content.FileName;
                    await dvm.Content.CopyToAsync(memoryStream);

                    document.Content = memoryStream.ToArray();
                }

                _context.Add(document);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(document));
        }