public async Task <IActionResult> Create([Bind("UserName,FirstName,LastName,Degree,University,JobPost,Company,Experience")] UserProfile profile, IFormFile CoverImage, IFormFile ProfileImage)
        {
            if (ModelState.IsValid)
            {
                if (ProfileImage != null && ProfileImage.Length > 0)
                {
                    var fileName = Path.GetFileName(ProfileImage.FileName);
                    var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\items", fileName);
                    using (var fileSteam = new FileStream(filePath, FileMode.Create))
                    {
                        await ProfileImage.CopyToAsync(fileSteam);
                    }
                    profile.ProfileImage = fileName;
                }
                if (CoverImage != null && CoverImage.Length > 0)
                {
                    var fileName = Path.GetFileName(CoverImage.FileName);
                    var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\items", fileName);
                    using (var fileSteam = new FileStream(filePath, FileMode.Create))
                    {
                        await CoverImage.CopyToAsync(fileSteam);
                    }
                    profile.CoverImage = fileName;
                }
                _context.Add(profile);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(profile));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("UserID,LastName,FirstMidName,Email,SavedHistoryID,Banned")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,email,profileImgUrl,friendsEmail")] SocialDetails socialDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(socialDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(socialDetails));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Slug,Content")] BlogPost blogPost)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogPost);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogPost));
        }
Beispiel #5
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create([Bind("ID,Name,Number,Company,Email,Skype,LI,FB,VK")] UserProfileModel userProfileModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userProfileModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(MyIndex)));
            }
            return(View(userProfileModel));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("Id,userName,alias,website,socialUrl,email,dob")] UserDetails userDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userDetails);
                await _context.SaveChangesAsync();

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