コード例 #1
0
        private async Task <AboutContainer> StoreAboutPicture(AboutContainer img, About about, IFormFile picture)
        {
            if (picture != null)
            {
                using (var stream = new System.IO.MemoryStream())
                {
                    await picture.CopyToAsync(stream);

                    img.Image   = stream.ToArray();
                    img.AboutId = about.Id;
                }
            }

            return(img);
        }
コード例 #2
0
        public IActionResult AboutContainerContent()
        {
            var comp  = _context.Companies.Where(x => x.CreatorId == User.Identity.GetUserId()).FirstOrDefault();
            var about = _context.AboutPages.Where(x => x.CompanyId == comp.Id).FirstOrDefault();
            List <AboutContainer> containers = new List <AboutContainer>();

            for (int i = 0; i < about.ContainerAmount; i++)
            {
                AboutContainer newCont = new AboutContainer()
                {
                    AboutId    = about.Id,
                    DivSection = i + 1
                };
                containers.Add(newCont);
            }
            AboutViewModel ViewModel = new AboutViewModel()
            {
                Comp       = comp,
                About      = about,
                Containers = containers
            };

            return(View(ViewModel));
        }
コード例 #3
0
        public async Task <IActionResult> AboutContainerContent(IFormCollection form, IFormFile pic1, IFormFile pic2, IFormFile pic3, IFormFile pic4, IFormFile pic5, IFormFile pic6)
        {
            var company = _context.Companies.Where(x => x.CreatorId == User.Identity.GetUserId()).FirstOrDefault();
            var about   = _context.AboutPages.Where(x => x.CompanyId == company.Id).FirstOrDefault();

            if (form["map+1"] == "on" || form["map+2"] == "on" || form["map+3"] == "on" || form["map+4"] == "on" || form["map+5"] == "on" || form["map+6"] == "on")
            {
                if (form["map+1"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 1;
                    newMap.AboutId    = about.Id;
                    newMap.Maps       = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["map+2"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 2;
                    newMap.AboutId    = about.Id;
                    newMap.Maps       = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["map+3"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 3;
                    newMap.AboutId    = about.Id;
                    newMap.Maps       = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["map+4"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 4;
                    newMap.AboutId    = about.Id;
                    newMap.Maps       = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["map+5"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 5;
                    newMap.AboutId    = about.Id;
                    newMap.Maps       = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["map+6"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 6;
                    newMap.AboutId    = about.Id;
                    newMap.Maps       = true;
                    _context.AboutContainers.Add(newMap);
                }
            }
            if (form["twitter+1"] == "on" || form["twitter+2"] == "on" || form["twitter+3"] == "on" || form["twitter+4"] == "on" || form["twitter+5"] == "on" || form["twitter+6"] == "on")
            {
                if (form["twitter+1"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 1;
                    newMap.AboutId    = about.Id;
                    newMap.Twitter    = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["twitter+2"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 2;
                    newMap.AboutId    = about.Id;
                    newMap.Twitter    = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["twitter+3"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 3;
                    newMap.AboutId    = about.Id;
                    newMap.Twitter    = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["twitter+4"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 4;
                    newMap.AboutId    = about.Id;
                    newMap.Twitter    = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["twitter+5"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 5;
                    newMap.AboutId    = about.Id;
                    newMap.Twitter    = true;
                    _context.AboutContainers.Add(newMap);
                }
                if (form["twitter+6"] == "on")
                {
                    AboutContainer newMap = new AboutContainer();
                    newMap.DivSection = 6;
                    newMap.AboutId    = about.Id;
                    newMap.Twitter    = true;
                    _context.AboutContainers.Add(newMap);
                }
            }
            if (pic1 != null || pic2 != null || pic3 != null || pic4 != null || pic5 != null || pic6 != null)
            {
                if (pic1 != null)
                {
                    AboutContainer newImage = new AboutContainer();
                    newImage = await StoreAboutPicture(newImage, about, pic1);

                    newImage.DivSection = 1;
                    newImage.AboutId    = about.Id;
                    _context.AboutContainers.Add(newImage);
                }
                if (pic2 != null)
                {
                    AboutContainer newImage = new AboutContainer();
                    newImage = await StoreAboutPicture(newImage, about, pic2);

                    newImage.DivSection = 2;
                    newImage.AboutId    = about.Id;
                    _context.AboutContainers.Add(newImage);
                }
                if (pic3 != null)
                {
                    AboutContainer newImage = new AboutContainer();
                    newImage = await StoreAboutPicture(newImage, about, pic3);

                    newImage.DivSection = 3;
                    newImage.AboutId    = about.Id;
                    _context.AboutContainers.Add(newImage);
                }
                if (pic4 != null)
                {
                    AboutContainer newImage = new AboutContainer();
                    newImage = await StoreAboutPicture(newImage, about, pic4);

                    newImage.DivSection = 4;
                    newImage.AboutId    = about.Id;
                    _context.AboutContainers.Add(newImage);
                }
                if (pic5 != null)
                {
                    AboutContainer newImage = new AboutContainer();
                    newImage = await StoreAboutPicture(newImage, about, pic5);

                    newImage.DivSection = 5;
                    newImage.AboutId    = about.Id;
                    _context.AboutContainers.Add(newImage);
                }
                if (pic6 != null)
                {
                    AboutContainer newImage = new AboutContainer();
                    newImage = await StoreAboutPicture(newImage, about, pic6);

                    newImage.DivSection = 6;
                    newImage.AboutId    = about.Id;
                    _context.AboutContainers.Add(newImage);
                }
            }
            for (int i = 0; i < about.ContainerAmount; i++)
            {
                string container = (i + 1).ToString();
                string check     = "textArea+" + container;
                if (form[check] != "")
                {
                    string         align   = "Alignment+" + container;
                    string         color   = "Color+" + container;
                    string         font    = "Font+" + container;
                    string         size    = "Size+" + container;
                    string         BgColor = "BackgroundColor+" + container;
                    AboutContainer newText = new AboutContainer();
                    newText.Text       = form[check];
                    newText.Align      = form[align];
                    newText.Color      = form[color];
                    newText.Font       = form[font];
                    newText.BgColor    = form[BgColor];
                    newText.FontSize   = form[size];
                    newText.DivSection = (i + 1);
                    newText.AboutId    = about.Id;
                    _context.AboutContainers.Add(newText);
                }
            }
            company.AboutSetupComplete = true;

            if (company.Contact)
            {
                _context.SaveChanges();
                return(RedirectToAction("ContactInitialSetup", "CompanyContact"));
            }
            else
            {
                company.SetupComplete = true;
                _context.SaveChanges();
                return(RedirectToAction("HomePage", "CompanyHome", new { id = company.Id }));
            }
        }