示例#1
0
        public ActionResult Form(int RestauranteId)
        {
            Session["restauranteAtual"] = rep.Busca(RestauranteId);
            Sugestoes sugestoes = new Sugestoes();

            return(View(sugestoes));
        }
示例#2
0
        public ActionResult Adiciona(Sugestoes sugestoes)
        {
            Restaurante restaurante = (Restaurante)Session["restauranteAtual"];
            Usuario     Usuario     = (Usuario)Session["usuarioLogado"];

            sugestoes.UsuarioId     = Usuario.UsuarioId;
            sugestoes.RestauranteId = rep.Busca(restaurante.RestauranteId).RestauranteId;
            srep.Adiciona(sugestoes);
            return(RedirectToAction("Index", "Restaurante"));
        }
示例#3
0
        public IActionResult Put([FromBody] Sugestoes item)
        {
            try
            {
                service.Put <SugestoesValidador>(item);

                return(Ok("Sugestão alterado com sucesso!"));
            }
            catch (ArgumentNullException ex)
            {
                return(NotFound(ex));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
示例#4
0
        public IActionResult Post([FromBody] Sugestoes item)
        {
            try
            {
                service.Post <SugestoesValidador>(item);

                return(Ok(new ObjectResult(item.CodSugestoes)));
            }
            catch (ArgumentNullException ex)
            {
                return(NotFound(ex));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
示例#5
0
        public void CustoValidacao()
        {
            SugestoesValidador SugestoesValidador = new SugestoesValidador();
            Sugestoes          s = new Sugestoes();

            s.CodCampanha    = 1;
            s.CodFuncionario = 1;
            s.CodSugestoes   = 1;
            s.Custo          = 200;
            s.DataFim        = DateTime.Now.AddYears(2);
            s.DataInicio     = DateTime.Now.AddYears(1);
            s.ReduçãoCusto   = 100;

            var resultado = SugestoesValidador.Validate(s);

            Assert.AreEqual(resultado.IsValid, false);
        }