Esempio n. 1
0
        public async Task <IActionResult> Edit(string back, int Id)
        {
            Background background = null;

            if (back == "BackgroundCor")
            {
                background = new BackgroundCor();
            }
            if (back == "BackgroundGradiente")
            {
                background = new BackgroundGradiente();
            }
            if (back == "BackgroundImagem")
            {
                background = new BackgroundImagem();
            }
            if (back == "Padrao")
            {
                background = await _context.Background.FirstOrDefaultAsync(b => b.Id == Id);

                ViewBag.condicao = true;
            }
            else
            {
                ViewBag.condicao = false;
            }

            ViewBag.back = back;
            ViewBag.id   = Id;
            return(PartialView(background));
        }
Esempio n. 2
0
        public async Task <string> _BackgroundGradiente([FromBody] BackgroundGradiente background)
        {
            var teste = await _context.Background.FirstOrDefaultAsync(b => b.Id == background.Id);

            if (teste == null)
            {
                _context.Add(background); await _context.SaveChangesAsync();

                return($"Chave do plano de fundo {background.Id}");
            }
            else
            {
                if (!(teste is BackgroundGradiente))
                {
                    _context.Remove(teste); await _context.SaveChangesAsync();

                    _context.Add(background); await _context.SaveChangesAsync();
                }
                else
                {
                    var back = (BackgroundGradiente)teste;
                    back.Grau = background.Grau;
                    _context.Update(back); await _context.SaveChangesAsync();
                }
                return("");
            }
        }
Esempio n. 3
0
        public IActionResult Create(string back, int Id)
        {
            Background background = null;

            if (back == "BackgroundCor")
            {
                background = new BackgroundCor();
            }
            if (back == "BackgroundGradiente")
            {
                background = new BackgroundGradiente();
            }
            if (back == "BackgroundImagem")
            {
                background = new BackgroundImagem();
            }

            ViewBag.id = Id;
            return(PartialView(background));
        }