Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Filess = await _context.Filess.FindAsync(id);

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



            string filePath = Path.Combine(Directory.GetCurrentDirectory(),
                                           "wwwroot",
                                           "File",
                                           Filess.Name + ".mp4");

            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }



            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SlidNew_produc = await _context.slidNew_Producs.FindAsync(id);

            if (SlidNew_produc != null)
            {
                _context.slidNew_Producs.Remove(SlidNew_produc);
                await _context.SaveChangesAsync();
            }


            string filePath = Path.Combine(Directory.GetCurrentDirectory(),
                                           "wwwroot",
                                           "Image",
                                           SlidNew_produc.NewBookName + ".jpg");

            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }



            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }



            _context.products.Add(Product);
            await _context.SaveChangesAsync();

            if (Productse.Picture?.Length > 0)
            {
                string filePath = Path.Combine(Directory.GetCurrentDirectory(),
                                               "wwwroot",
                                               "Image",
                                               Product.Name + Path.GetExtension(Productse.Picture.FileName));
                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    Productse.Picture.CopyTo(stream);
                }
            }



            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 4
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync(/*[FromServices] IWebHostEnvironment env*/)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }



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



            if (Add.Pictore?.Length > 0)
            {
                string filePath = Path.Combine(Directory.GetCurrentDirectory(),
                                               "wwwroot",
                                               "File",
                                               Filess.Name + Path.GetExtension(Add.Pictore.FileName));
                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    Add.Pictore.CopyTo(stream);
                }
            }



            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 5
0
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryExists(Category.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 6
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.AuthorNames.Add(CategoreAuthorName);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 7
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.PRODUCTTOSLIDERs.Add(PRODUCTTOSLIDER);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CategoreAuthorName = await _context.AuthorNames.FindAsync(id);

            if (CategoreAuthorName != null)
            {
                _context.AuthorNames.Remove(CategoreAuthorName);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PRODUCTTOSLIDER = await _context.PRODUCTTOSLIDERs.FindAsync(id);

            if (PRODUCTTOSLIDER != null)
            {
                _context.PRODUCTTOSLIDERs.Remove(PRODUCTTOSLIDER);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 10
0
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(Product.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }



            if (Productse.Picture?.Length > 0)
            {
                string filePath = Path.Combine(Directory.GetCurrentDirectory(),
                                               "wwwroot",
                                               "Image",
                                               Product.Name + Path.GetExtension(Productse.Picture.FileName));
                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    Productse.Picture.CopyTo(stream);
                }
            }



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