Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (UploadedImage != null)
            {
                var file = "./wwwroot/img/" + UploadedImage.FileName;
                using (var fileStream = new FileStream(file, FileMode.Create))
                {
                    await UploadedImage.CopyToAsync(fileStream);
                }
            }

            Blog blog = new Blog();

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            blog.Date   = DateTime.Now;
            blog.Header = Header;
            blog.Text   = Text;
            blog.Image  = UploadedImage != null ? UploadedImage.FileName : "";
            blog.UserId = userId;

            _context.Blog.Add(blog);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        private async Task UploadImageToFileSystemAsync(string newImagePath)
        {
            var file = Path.Combine(environment.WebRootPath, newImagePath);

            using (var fileStream = new FileStream(file, FileMode.Create))
            {
                await UploadedImage.CopyToAsync(fileStream);
            }
        }
Beispiel #3
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (UploadedImage != null)
            {
                var file = "./wwwroot/img/" + UploadedImage.FileName;
                using (var fileStream = new FileStream(file, FileMode.Create))
                {
                    await UploadedImage.CopyToAsync(fileStream);
                }
            }

            Image.ImageFile = UploadedImage != null ? UploadedImage.FileName : "";

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

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (UploadedImage != null)
            {
                var    fileFolder     = Path.Combine(webHostEnvironment.WebRootPath, "images");
                var    uniqueFileName = UploadedImage.FileName;
                string filePath       = Path.Combine(fileFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    await UploadedImage.CopyToAsync(fileStream);
                }
            }

            MyPortfolioInfo myInfo = new MyPortfolioInfo();

            //foodItem.Purchased = (Request.Form["Purchased"].ToString()).Contains("on") ? true : false;
            //var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            myInfo.FirstName          = FirstName;
            myInfo.LasttName          = LasttName;
            myInfo.Image              = UploadedImage != null ? UploadedImage.FileName : "";
            myInfo.ProfileDiscription = ProfileDiscription;
            myInfo.Languages          = Languages;
            myInfo.MyProjectsLink     = MyProjectsLink;
            myInfo.ContactNumber      = ContactNumber;
            myInfo.Email              = Email;
            myInfo.LinkedInLink       = LinkedInLink;
            myInfo.School1            = School1;
            myInfo.Course1            = Course1;
            myInfo.Course2            = Course2;

            myInfo.Course3  = Course3;
            myInfo.Course4  = Course4;
            myInfo.Course5  = Course5;
            myInfo.Course6  = Course6;
            myInfo.Course7  = Course7;
            myInfo.Course8  = Course8;
            myInfo.Course9  = Course9;
            myInfo.Course10 = Course10;

            myInfo.School2          = School2;
            myInfo.School2Education = School2Education;


            myInfo.TecnicalCompitences = TecnicalCompitences;

            myInfo.WorkExprience1 = WorkExprience1;
            myInfo.WorkExprience2 = WorkExprience2;
            myInfo.WorkExprience3 = WorkExprience3;
            myInfo.WorkExprience4 = WorkExprience4;
            myInfo.WorkExprience5 = WorkExprience5;


            myInfo.References = References;



            _context.MyPortfolioInfo.Add(myInfo);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }