public async Task <IActionResult> Delete(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            NewEvent dbnewEvent = _db.NewEvents.Where(w => w.IsDeleted == false).Include(p => p.NewManagmentEvents).ThenInclude(c => c.NewManagmentBoard).FirstOrDefault(f => f.Id == Id);

            _db.NewEvents.Remove(dbnewEvent);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Delete(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }

            Teacher delteacher = _db.Teachers.Include(c => c.Skills).FirstOrDefault(c => c.Id == Id);

            _db.Teachers.Remove(delteacher);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Update(EudoHomeChoose eudoHome)
        {
            if (ModelState["Photo"].ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid)
            {
                return(View());
            }
            if (!eudoHome.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Sekil fayli daxil edin");
                return(View());
            }
            if (eudoHome.Photo.MaxLength(300))
            {
                ModelState.AddModelError("Photo", "Seklin olcusu 300kb-dan boyuk olmamalidir");
                return(View());
            }
            EudoHomeChoose dbeudohome = _db.EudoHomeChooses.FirstOrDefault();

            if (dbeudohome == null)
            {
                return(NotFound());
            }
            string folderpath = Path.Combine("img", "slider");

            Helper.DeleteImage(_env.WebRootPath, folderpath, dbeudohome.Image);

            string FileName = await eudoHome.Photo.SaveImage(_env.WebRootPath, folderpath);

            dbeudohome.Image       = FileName;
            dbeudohome.Title       = eudoHome.Title;
            dbeudohome.Description = eudoHome.Description;
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Delete(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            Blog blogs = _db.Blogs.Include(c => c.BlogAndTeachers).FirstOrDefault(v => v.Id == Id);

            if (blogs == null)
            {
                return(NotFound());
            }
            _db.Blogs.Remove(blogs);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Delete(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            NewManagmentBoard newManagmentBoard = _db.NewManagmentBoards.Include(c => c.NewManagmentEvents).ThenInclude(p => p.NewEvent).FirstOrDefault(d => d.Id == Id);

            if (newManagmentBoard == null)
            {
                return(NotFound());
            }
            _db.NewManagmentBoards.Remove(newManagmentBoard);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #6
0
        public async Task <IActionResult> Delete(int?Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            Course delCourse = _db.Courses.FirstOrDefault(c => c.Id == Id);

            if (delCourse == null)
            {
                return(NotFound());
            }
            _db.Courses.Remove(delCourse);

            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            NoticeProfession noticeProfession = await _db.NoticeProfessions.FindAsync(id);

            if (noticeProfession == null)
            {
                return(NotFound());
            }


            _db.NoticeProfessions.Remove(noticeProfession);
            await _db.SaveChangesAsync();

            return(RedirectToAction("index"));
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Slider slider = await _db.Sliders.FindAsync(id);

            if (slider == null)
            {
                return(NotFound());
            }

            string folderpath = Path.Combine("img", "slider");

            Helper.DeleteImage(_env.WebRootPath, folderpath, slider.Image);


            _db.Sliders.Remove(slider);
            await _db.SaveChangesAsync();

            return(RedirectToAction("index"));
        }
Beispiel #9
0
        public IActionResult Update(TakeVideo takevideo)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            TakeVideo dbtakevideo = _db.TakeVideos.FirstOrDefault();

            dbtakevideo.Title = takevideo.Title;
            dbtakevideo.Video = takevideo.Video;
            _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task Change(Todo todo)
        {
            if (todo == null)
            {
                throw new Exception("Todo cannot be NULL");
            }
            if (todo.Id < 0)
            {
                throw new Exception("Id must be greater than ZERO");
            }
            _context.Entry(todo).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            var rowsaffected = await _context.SaveChangesAsync();

            if (rowsaffected != 1)
            {
                throw new Exception("Change FAILED!!!");
            }
            return;
        }
Beispiel #11
0
        public async Task <IActionResult> IsActivate(string Id, bool IsActivated)
        {
            if (Id == null)
            {
                return(NotFound());
            }
            User user = await _userManager.FindByIdAsync(Id);

            if (user == null)
            {
                return(NotFound());
            }
            user.IsActivated = IsActivated;
            await _db.SaveChangesAsync();



            return(Ok(user));
        }
        public async Task <Todo> Create(Todo todo)
        {
            if (todo == null)
            {
                throw new Exception("Todo cannot be NULL");
            }
            if (todo.Id != 0)
            {
                throw new Exception("Todo ID must be ZERO");
            }
            await _context.Todos.AddAsync(todo);

            var rowsaffected = await _context.SaveChangesAsync();

            if (rowsaffected != 1)
            {
                throw new Exception("Create FAILED!!!");
            }
            return(todo);
        }
Beispiel #13
0
        public async Task <IActionResult> Update(Testimonial testmonial)
        {
            if (ModelState["PhotoFrond"].ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid &&
                ModelState["PhotoBack"].ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid)
            {
                return(View());
            }


            if (!testmonial.PhotoFrond.IsImage() && !testmonial.PhotoBack.IsImage())
            {
                ModelState.AddModelError("Photo", "Sekil fayli daxil edin");
                return(View());
            }
            if (testmonial.PhotoFrond.MaxLength(300) && testmonial.PhotoFrond.MaxLength(300))
            {
                ModelState.AddModelError("Photo", "Seklin olcusu 300kb-dan artiq olmamalidir");
                return(View());
            }
            Testimonial dbtestmonial = _db.Testimonials.FirstOrDefault();
            string      foldername   = Path.Combine("img", "testimonial");

            Helper.DeleteImage(_env.WebRootPath, foldername, dbtestmonial.Image);
            Helper.DeleteImage(_env.WebRootPath, foldername, dbtestmonial.BackgroundImage);

            string FileName = await testmonial.PhotoFrond.SaveImage(_env.WebRootPath, foldername);

            string FileNameBack = await testmonial.PhotoBack.SaveImage(_env.WebRootPath, foldername);

            dbtestmonial.Image           = FileName;
            dbtestmonial.BackgroundImage = FileNameBack;
            dbtestmonial.Job             = testmonial.Job;
            dbtestmonial.Description     = testmonial.Description;
            dbtestmonial.CourseName      = testmonial.CourseName;
            dbtestmonial.Name            = testmonial.Name;
            dbtestmonial.Surname         = testmonial.Surname;

            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Update(WelcomeEduHome welcomeeduhome)
        {
            if (ModelState["Photo"].ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid)
            {
                return(View());
            }


            if (!welcomeeduhome.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Sekil fayli daxil edin");
                return(View());
            }
            if (welcomeeduhome.Photo.MaxLength(300))
            {
                ModelState.AddModelError("Photo", "Seklin olcusu 300kb-dan artiq olmamalidir");
                return(View());
            }
            WelcomeEduHome dbwelcomeduhome = _db.WelcomeEduHomes.FirstOrDefault();
            string         foldername      = Path.Combine("img", "about");

            Helper.DeleteImage(_env.WebRootPath, foldername, dbwelcomeduhome.Image);


            string FileName = await welcomeeduhome.Photo.SaveImage(_env.WebRootPath, foldername);


            dbwelcomeduhome.Image       = FileName;
            dbwelcomeduhome.Title       = welcomeeduhome.Title;
            dbwelcomeduhome.Description = welcomeeduhome.Description;



            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #15
0
 public async Task CompleteAsync()
 {
     await _context.SaveChangesAsync();
 }