Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("UserID,LastName,FirstMidName,Email,SavedHistoryID,Banned")] User user)
        {
            if (id != user.UserID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,email,profileImgUrl,friendsEmail")] SocialDetails socialDetails)
        {
            if (id != socialDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(socialDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SocialDetailsExists(socialDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(socialDetails));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Slug,Content")] BlogPost blogPost)
        {
            if (id != blogPost.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blogPost);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogPostExists(blogPost.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogPost));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Number,Company,Email,Skype,LI,FB,VK")] UserProfileModel userProfileModel)
        {
            if (id != userProfileModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userProfileModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserProfileModelExists(userProfileModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(MyIndex)));
            }
            return(View(userProfileModel));
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,userName,alias,website,socialUrl,email,dob")] UserDetails userDetails)
        {
            if (id != userDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserDetailsExists(userDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userDetails));
        }
        public async Task <IActionResult> Edit(string username, [Bind("UserName,FirstName,LastName,Degree,University,JobPost,Company,Experience")] UserProfile profile, IFormFile CoverImage, IFormFile ProfileImage)
        {
            if (username != profile.UserName)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    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.Update(profile);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserProfileExists(profile.UserName))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(profile));
        }