コード例 #1
0
        public async Task <IActionResult> Create([Bind(include: "Title, TitleAz, TitleRu, Photo")] Slider slider)
        {
            if (!ModelState.IsValid)
            {
                return(View(slider));
            }

            if (slider.Photo == null)
            {
                ModelState.AddModelError("Photo", "Photo can't be null");
                return(View(slider));
            }

            if (!slider.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Photo type is not valid...");
                return(View(slider));
            }

            slider.Image = await slider.Photo.SaveAsync(_env.WebRootPath, "img", "slider");

            _context.Sliders.Add(slider);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task <IActionResult> Service(IFormCollection keys)
        {
            Complaint complaint = new Complaint();

            if (User.Identity.IsAuthenticated)
            {
                var UserEmail = await _userManager.FindByEmailAsync(HttpContext.User.Identity.Name);

                complaint.UserId = UserEmail.Id;
            }

            complaint.Fullname = keys["namecomplaint"];
            complaint.Email    = keys["emailcomplaint"];
            if (User.Identity.IsAuthenticated)
            {
                var UserEmail = await _userManager.FindByEmailAsync(HttpContext.User.Identity.Name);

                if (UserEmail.ToString() != complaint.Email)
                {
                    return(RedirectToAction("WarningPage", "Home"));
                }
            }
            complaint.Subject = keys["subjectcomplaint"];
            complaint.Message = keys["messagecomplaint"];


            _context.Complaints.Add(complaint);
            await _context.SaveChangesAsync();

            Status.Stat = "success";

            return(RedirectToAction("Service", "Home"));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind(include: "FullName, Profession, Profession_Az, Profession_Ru, Desc, Desc_Az,Desc_Ru, Photo")] Testimonial testimonial)
        {
            if (!ModelState.IsValid)
            {
                return(View(testimonial));
            }

            if (testimonial.Photo == null)
            {
                ModelState.AddModelError("Photo", "Photo can't be null");
                return(View(testimonial));
            }

            if (!testimonial.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Photo type is not valid...");
                return(View(testimonial));
            }

            testimonial.Image = await testimonial.Photo.SaveAsync(_env.WebRootPath, "img", "testimonial");

            _context.Testimonials.Add(testimonial);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind(include: "Title, Title_Az, Title_Ru, Description, Description_Az, Description_Ru, Photo")] Blog blog)
        {
            if (!ModelState.IsValid)
            {
                return(View(blog));
            }

            if (blog.Photo == null)
            {
                ModelState.AddModelError("Photo", "Photo can't be null");
                return(View(blog));
            }

            if (!blog.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Photo type is not valid...");
                return(View(blog));
            }

            blog.Image = await blog.Photo.SaveAsync(_env.WebRootPath, "img", "blog");

            blog.Date = DateTime.Now.ToString("MMM dd, yyyy");

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

            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public async Task <IActionResult> Delete(int Id)
        {
            var DeletingElement = await _context.Complaints.FindAsync(Id);

            _context.Remove(DeletingElement);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Service"));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind(include: "IconClass, Title, Title_Az, Title_Ru, Description, Description_Az,Description_Ru")] WhyChooseUs chooseUs)
        {
            if (!ModelState.IsValid)
            {
                return(View(chooseUs));
            }

            _context.WhyChooseUs.Add(chooseUs);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind(include: "Description, Description_Az, Description_Ru")] About about)
        {
            if (!ModelState.IsValid)
            {
                return(View(about));
            }

            _context.Abouts.Add(about);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }