Exemple #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            fileuploadVM.file     = files.FirstOrDefault();
            fileuploadVM.FileName = files.FirstOrDefault().FileName;
            fileuploadVM.fileSize = files.FirstOrDefault().Length;
            fileuploadVM.Type     = fileuploadVM.Type;
            fileuploadVM.save();

            _context.Attach(fileuploadVM).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FileUploadExists(fileuploadVM.id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./FileUploadIndex"));
        }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(FirebaseSetting).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FirebaseSettingExists(FirebaseSetting.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./firebaseIndex"));
        }
Exemple #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var webpath  = _env.WebRootPath;
            var filePath = Path.Combine(webpath, "images/" + firebasesettingvm.file.FileName);

            using (var fileStream = new FileStream(filePath, FileMode.Create))
            {
                await firebasesettingvm.file.CopyToAsync(fileStream);
            }

            //var fileData = await FileHelpers.ProcessFormFile(firebasesettingvm.file, ModelState);

            //firebasesettingvm.GoogleServicesData = fileData;
            // firebasesettingvm.GoogleServicesSize = firebasesettingvm.file.Length;
            FirebaseSetting model = new FirebaseSetting();

            _mapper.Map(firebasesettingvm, model);
            _context.FirebaseSettings.Add(model);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./firebaseIndex"));
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FirebaseSetting = await _context.FirebaseSettings.FindAsync(id);

            if (FirebaseSetting != null)
            {
                _context.FirebaseSettings.Remove(FirebaseSetting);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./firebaseIndex"));
        }
Exemple #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FileUpload = await _context.FileUploads.FindAsync(id);

            if (FileUpload != null)
            {
                _context.FileUploads.Remove(FileUpload);
                await _context.SaveChangesAsync();
            }

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