Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("Id,Fullname,Images,Minidescription,Special,Experience,Phone,Email,Sliderdesc,Images,TitleDesc")] Teacherr teacherr, IFormFile Images)
        {
            if (ModelState.IsValid)
            {
                if (Extension.CheckImg(Images, Extension.MAxfileSize))
                {
                    try
                    {
                        teacherr.Images = Extension.SaveImg(Images, path);
                    }
                    catch
                    {
                        ModelState.AddModelError("Img", "Img is not correct");
                    }
                }
                else
                {
                    ModelState.AddModelError("Img", "Img is not correct");
                }
                _context.Add(teacherr);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Miniage,Maxage")] Age age)
        {
            if (ModelState.IsValid)
            {
                _context.Add(age);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(age));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] BlogCategory blogCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogCategory));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Blogdesc1,Blogdesc2,Title,Date,Status,BlogcategoryId,UserId")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"]         = new SelectList(_context.Users, "Id", "Fullname", blog.UserId);
            ViewData["BlogcategoryId"] = new SelectList(_context.BlogCategories, "Id", "Name", blog.BlogcategoryId);

            return(View(blog));
        }
        public async Task <IActionResult> CommentLis(string description, int?postId)
        {
            try
            {
                var user = await _userManager.GetUserAsync(User);

                if (User == null || User.Identity == null || !User.Identity.IsAuthenticated)
                {
                    return(Json(0));
                }
                string userId = user.Id;

                Comments comment = new Comments();
                comment.BlogId     = postId.Value;
                comment.UserId     = userId;
                comment.Date       = DateTime.UtcNow;
                comment.Descripton = description;
                context.Add(comment);
                await context.SaveChangesAsync();

                return(PartialView("_PArtialcomment", comment));
            }
            catch (Exception)
            {
                return(RedirectToAction());
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> Entrolls(Entroll entroll)
        {
            if (ModelState.IsValid)
            {
                context.Add(entroll);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("Id,BlogId")] GaleryBlog galeryBlog, IEnumerable <IFormFile> ImageBlog)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in ImageBlog)
                {
                    if (Extension.CheckImg(item, Extension.MAxfileSize))
                    {
                        try
                        {
                            galeryBlog.ImageBlog = Extension.SaveImg(item, path);
                        }
                        catch
                        {
                            return(View(galeryBlog));
                        }
                    }
                    else
                    {
                        return(View(galeryBlog));
                    }
                    GaleryBlog gales = new GaleryBlog
                    {
                        Id        = galeryBlog.Id,
                        ImageBlog = galeryBlog.ImageBlog,
                        BlogId    = galeryBlog.BlogId
                    };


                    _context.Add(gales);


                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["BlogId"] = new SelectList(_context.Blogs, "Id", "Name", galeryBlog.BlogId);
            return(View(galeryBlog));
        }
        public async Task <IActionResult> Create([Bind(include: "Id,Name,Price,Description,Size,Openhourse,Closehours,Startime,TeacherId,AgeeId,CategoryId")] Classroomm classroomm, IFormFile Iamgename)
        {
            if (ModelState.IsValid)
            {
                if (Iamgename != null)
                {
                    if (Extension.CheckImg(Iamgename, Extension.MAxfileSize))
                    {
                        try
                        {
                            classroomm.Iamgename = Extension.SaveImg(Iamgename, path);
                        }
                        catch
                        {
                            return(View(classroomm));
                        }
                    }
                    else
                    {
                        return(View(classroomm));
                    }
                }
                else
                {
                    return(RedirectToAction("Create", "Classroomms"));
                }



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

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AgeeId"]     = new SelectList(_context.Ages, "Id", "Id", classroomm.AgeeId);
            ViewData["CategoryId"] = new SelectList(_context.Categoryies, "Id", "Name", classroomm.CategoryId);
            ViewData["TeacherId"]  = new SelectList(_context.Teacherrs, "Id", "Fullname", classroomm.TeacherId);
            return(View(classroomm));
        }