private void paocerealList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lst = AlimentoViewModel.listarPaes();
            thisApp.Actives.ActiveImagem      = lst[paocerealList.SelectedIndex].Img_source;
            thisApp.Actives.IdAlimento_Select = paocerealList.SelectedIndex + 1;

            switch (App.Current.Actives.IdRefeicao_Select)
            {
            case 1:
                App.Current.Actives.R_cafedamanha.Paofk = paocerealList.SelectedIndex + 1;
                break;

            case 2:
                App.Current.Actives.R_lanchedamanha.Paofk = paocerealList.SelectedIndex + 1;
                break;

            case 4:
                App.Current.Actives.R_lanchetarde.Paofk = paocerealList.SelectedIndex + 1;
                break;

            case 6:
                App.Current.Actives.R_lanchenoite.Paofk = paocerealList.SelectedIndex + 1;
                break;

            default:
                break;
            }

            this.NavigationService.GoBack();
        }
Beispiel #2
0
        public ActionResult Edit(AlimentoViewModel alimento)
        {
            if (ModelState.IsValid)
            {
                var alimentoDomain = Mapper.Map <AlimentoViewModel, Alimento>(alimento);
                _alimentoApp.Update(alimentoDomain);

                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("ErroEdit", "Não foi possível alterar o Registro!"); // Testando mensagens de erro
            return(View(alimento));
        }
        //FIM EVENTOS IMAGENS

        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.Actives.ActiveImagem != null)
            {
                thisImagem.Source = new BitmapImage(new Uri(App.Current.Actives.ActiveImagem, UriKind.RelativeOrAbsolute));
                App.Current.Actives.ActiveImagem = null;
            }
            if (App.Current.Actives.R_cafedamanha.Id_cafedamanha != 0)
            {
                this.imgFrutas.Source          = new BitmapImage(new Uri(AlimentoViewModel.listarFrutas()[App.Current.Actives.R_cafedamanha.Frutafk - 1].Img_source, UriKind.RelativeOrAbsolute));
                this.imgcopo.Source            = new BitmapImage(new Uri(AlimentoViewModel.listarCopos()[App.Current.Actives.R_cafedamanha.Liquidofk - 1].Img_source, UriKind.RelativeOrAbsolute));
                this.imgCafePaesCereais.Source = AlimentoViewModel.listarPaes()[App.Current.Actives.R_cafedamanha.Paofk - 1].ImgConvertedSource();
                cafedamanhaR = App.Current.Actives.R_cafedamanha;
            }
        }
        //FIM EVENTOS IMAGENS

        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (App.Current.Actives.ActiveImagem != null)
            {
                thisImagem.Source = new BitmapImage(new Uri(App.Current.Actives.ActiveImagem, UriKind.RelativeOrAbsolute));
                App.Current.Actives.ActiveImagem = null;
            }
            if (App.Current.Actives.R_lanchetarde.Id_lanchedatarde != 0)
            {
                this.imgLANCHETardeFrutas.Source = new BitmapImage(new Uri(AlimentoViewModel.listarFrutas()[App.Current.Actives.R_lanchetarde.Frutafk - 1].Img_source, UriKind.RelativeOrAbsolute));
                this.imgcopo.Source = new BitmapImage(new Uri(AlimentoViewModel.listarCopos()[App.Current.Actives.R_lanchetarde.Liquidofk - 1].Img_source, UriKind.RelativeOrAbsolute));
                this.imgLANCHETardePaesCereais.Source = new BitmapImage(new Uri(AlimentoViewModel.listarPaes()[App.Current.Actives.R_lanchetarde.Paofk - 1].Img_source, UriKind.RelativeOrAbsolute));
                lanchetardeR = App.Current.Actives.R_lanchetarde;
            }
        }
Beispiel #5
0
        public ActionResult Create(AlimentoViewModel alimento)
        {
            if (ModelState.IsValid)
            {
                var alimentoDomain = Mapper.Map <AlimentoViewModel, Alimento>(alimento);
                _alimentoApp.Add(alimentoDomain);

                return(RedirectToAction("Index"));
            }
            ViewBag.id_unid = new SelectList(
                _unidadeApp.GetAll(), // Todas as unidades
                "id_unid",            // Valor de cada objeto na lista - Referencia a classe Unidade
                "unid_simbolo",       // Valor a ser exibido na lista - Referencia a classe Unidade
                alimento.id_unid      // Valor selecionado no Drop Down
                );
            return(View(alimento));
        }
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (App.Current.Actives.ActiveImagem != null)
     {
         thisImagem.Source = new BitmapImage(new Uri(App.Current.Actives.ActiveImagem, UriKind.RelativeOrAbsolute));
         App.Current.Actives.ActiveImagem = null;
     }
     if (App.Current.Actives.R_almoco.Id_almoco != 0)
     {
         this.imgAlmocoFrutas.Source    = new BitmapImage(new Uri(AlimentoViewModel.listarFrutas()[App.Current.Actives.R_almoco.Frutafk - 1].Img_source, UriKind.RelativeOrAbsolute));
         this.imgcopo.Source            = new BitmapImage(new Uri(AlimentoViewModel.listarCopos()[App.Current.Actives.R_almoco.Liquidofk - 1].Img_source, UriKind.RelativeOrAbsolute));
         this.imgAlmocoVegetais.Source  = new BitmapImage(new Uri(AlimentoViewModel.listarvegetal()[App.Current.Actives.R_almoco.Vegetalfk - 1].Img_source, UriKind.RelativeOrAbsolute));
         this.imgAlmocoProteinas.Source = new BitmapImage(new Uri(AlimentoViewModel.listarProteinas()[App.Current.Actives.R_almoco.Proteinafk - 1].Img_source, UriKind.RelativeOrAbsolute));
         this.imgAlmocoGraos.Source     = new BitmapImage(new Uri(AlimentoViewModel.listarGraoIntegral()[App.Current.Actives.R_almoco.GraoIntegralfk - 1].Img_source, UriKind.RelativeOrAbsolute));
         almocoR = App.Current.Actives.R_almoco;
     }
 }
        public ActionResult Form(AlimentoViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var alimento = new Alimento();

            alimento           = Mapper.Map <Alimento>(viewModel);
            alimento.UsuarioId = User.Identity.GetUserId();
            alimento.DataHora  = viewModel.ObterDataCompleta();

            var result = alimento.Validar();

            if (!result.IsValid)
            {
                foreach (var validation in result.Errors)
                {
                    if (validation.PropertyName.Equals("DataHora"))
                    {
                        ModelState.AddModelError("", validation.ErrorMessage);
                    }
                    else
                    {
                        ModelState.AddModelError(validation.PropertyName, validation.ErrorMessage);
                    }
                }
                return(View(viewModel));
            }

            if (string.IsNullOrEmpty(alimento.Id))
            {
                _unitOfWork.AlimentoRepository.Add(alimento);
            }
            else
            {
                _unitOfWork.AlimentoRepository.Update(alimento);
            }

            _unitOfWork.Commit();

            return(RedirectToAction("Index"));
        }
        public ViewResult Form(string id = null)
        {
            var viewModel = new AlimentoViewModel();

            if (!string.IsNullOrWhiteSpace(id))
            {
                var alimento = _unitOfWork.AlimentoRepository.Get(id);
                viewModel      = Mapper.Map <AlimentoViewModel>(alimento);
                viewModel.Data = alimento.DataHora;
                viewModel.Hora = alimento.DataHora;
                ViewBag.Titulo = "Editar";
                return(View(viewModel));
            }

            ViewBag.Titulo = "Cadastrar";
            viewModel.Data = DateTime.Now;
            viewModel.Hora = DateTime.Now;

            return(View(viewModel));
        }
        private void GraoList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lst = AlimentoViewModel.listarGraoIntegral();
            thisApp.Actives.ActiveImagem      = lst[GraoList.SelectedIndex].Img_source;
            thisApp.Actives.IdAlimento_Select = GraoList.SelectedIndex + 1;
            switch (App.Current.Actives.IdRefeicao_Select)
            {
            case 3:
                App.Current.Actives.R_almoco.GraoIntegralfk = GraoList.SelectedIndex + 1;
                break;

            case 5:
                App.Current.Actives.R_jantar.GraoIntegralfk = GraoList.SelectedIndex + 1;
                break;

            default:
                break;
            }
            this.NavigationService.GoBack();
        }
        private void FrutaList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lst = AlimentoViewModel.listarFrutas();
            App.Current.Actives.ActiveImagem      = lst[FrutaList.SelectedIndex].Img_source;
            App.Current.Actives.IdAlimento_Select = FrutaList.SelectedIndex + 1;
            switch (App.Current.Actives.IdRefeicao_Select)
            {
            case 1:
                App.Current.Actives.R_cafedamanha.Frutafk = FrutaList.SelectedIndex + 1;
                break;

            case 2:
                App.Current.Actives.R_lanchedamanha.Frutafk = FrutaList.SelectedIndex + 1;
                break;

            case 3:
                App.Current.Actives.R_almoco.Frutafk = FrutaList.SelectedIndex + 1;
                break;

            case 4:
                App.Current.Actives.R_lanchetarde.Frutafk = FrutaList.SelectedIndex + 1;
                break;

            case 5:
                App.Current.Actives.R_jantar.Frutafk = FrutaList.SelectedIndex + 1;
                break;

            case 6:
                App.Current.Actives.R_lanchenoite.Frutafk = FrutaList.SelectedIndex + 1;
                break;

            default:
                break;
            }
            this.NavigationService.GoBack();
        }
Beispiel #11
0
 public Alimentos()
 {
     InitializeComponent();
     BindingContext = viewModel = new AlimentoViewModel();
 }
Beispiel #12
0
        public FrmProteinas()
        {
            InitializeComponent();

            this.proteinasList.ItemsSource = AlimentoViewModel.listarProteinas();
        }
        public GraoIntegral()
        {
            InitializeComponent();

            this.GraoList.ItemsSource = AlimentoViewModel.listarGraoIntegral();
        }
        public FrmFrutas()
        {
            InitializeComponent();

            this.FrutaList.ItemsSource = AlimentoViewModel.listarFrutas();
        }
Beispiel #15
0
 public FrmCopo()
 {
     InitializeComponent();
     this.CopoList.ItemsSource = AlimentoViewModel.listarCopos();
 }
Beispiel #16
0
        public FrmVegetais()
        {
            InitializeComponent();

            this.vegetalList.ItemsSource = AlimentoViewModel.listarvegetal();
        }
        public FrmCafe()
        {
            InitializeComponent();

            this.paocerealList.ItemsSource = AlimentoViewModel.listarPaes();
        }
Beispiel #18
0
        public void trocarNomeHeader()
        {
            #region Verificação do tipo de qual alimento será referenciado
            //Lista de alimentos a exibir;
            List <AlimentoView> lstDados = new List <AlimentoView>();

            switch (App.Current.Actives.IdRefeicao_Select)
            {
            case 1:
                // Nome do cabeçalho:
                this.txtTitulo1.Text = "café da manhã";
                // Recolhando os alimentos que serão exibidos:
                lstDados.Add(
                    AlimentoViewModel.listarFrutas()[
                        CafedaManhaViewModel.listar()[atual.Cafedamanha_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarPaes()[
                        CafedaManhaViewModel.listar()[atual.Cafedamanha_fk - 1].Paofk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarCopos()[
                        CafedaManhaViewModel.listar()[atual.Cafedamanha_fk - 1].Liquidofk - 1]);
                break;

            case 2:
                // Nome do cabeçalho:
                this.txtTitulo1.Text = "lanche da manhã";
                // Recolhando os alimentos que serão exibidos:
                lstDados.Add(
                    AlimentoViewModel.listarFrutas()[
                        LanchedaManhaViewModel.listar()[atual.Lanchemanha_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarCopos()[
                        LanchedaManhaViewModel.listar()[atual.Lanchemanha_fk - 1].Liquidofk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarPaes()[
                        LanchedaManhaViewModel.listar()[atual.Lanchemanha_fk - 1].Paofk - 1]);
                break;

            case 3:
                // Nome do cabeçalho:
                this.txtTitulo1.Text = "almoço";
                // Recolhando os alimentos que serão exibidos:
                lstDados.Add(
                    AlimentoViewModel.listarCopos() [
                        AlmocoViewModel.listar()[atual.Almoco_fk - 1].Liquidofk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarGraoIntegral()[
                        AlmocoViewModel.listar()[atual.Almoco_fk - 1].GraoIntegralfk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarvegetal()[
                        AlmocoViewModel.listar()[atual.Almoco_fk - 1].Vegetalfk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarFrutas()[
                        AlmocoViewModel.listar()[atual.Almoco_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarProteinas()[
                        AlmocoViewModel.listar()[atual.Almoco_fk - 1].Proteinafk - 1]);
                break;

            case 4:
                // Nome do cabeçalho:
                this.txtTitulo1.Text = "lanche da tarde";
                // Exibe as imagens correspondentes no prato e copo:
                lstDados.Add(
                    AlimentoViewModel.listarFrutas()[
                        LanchedaTardeViewModel.listar()[atual.Lanchetarde_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarCopos()[
                        LanchedaTardeViewModel.listar()[atual.Lanchetarde_fk - 1].Liquidofk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarPaes()[
                        LanchedaTardeViewModel.listar()[atual.Lanchetarde_fk - 1].Paofk - 1]);
                break;

            case 5:
                // Nome do cabeçalho:
                this.txtTitulo1.Text = "jantar";
                // Exibe as imagens correspondentes no prato e copo:
                lstDados.Add(
                    AlimentoViewModel.listarCopos() [
                        JantaViewModel.listar()[atual.Jantar_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarGraoIntegral()[
                        JantaViewModel.listar()[atual.Jantar_fk - 1].GraoIntegralfk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarvegetal()[
                        JantaViewModel.listar()[atual.Jantar_fk - 1].Vegetalfk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarFrutas()[
                        JantaViewModel.listar()[atual.Jantar_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarProteinas()[
                        JantaViewModel.listar()[atual.Jantar_fk - 1].Proteinafk - 1]);
                break;

            case 6:
                // Nome do cabeçalho:
                this.txtTitulo1.Text = "lanche da noite";
                // Exibe as imagens correspondentes no prato e copo:
                lstDados.Add(
                    AlimentoViewModel.listarFrutas()[
                        LanchedaNoiteViewModel.listar()
                        [atual.Lanchedanoite_fk - 1].Frutafk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarCopos()[
                        LanchedaNoiteViewModel.listar()
                        [atual.Lanchedanoite_fk - 1].Liquidofk - 1]);
                lstDados.Add(
                    AlimentoViewModel.listarPaes()[
                        LanchedaNoiteViewModel.listar()
                        [atual.Lanchedanoite_fk - 1].Paofk - 1]);

                break;

            default:
                break;
            }
            // Fim da Listagem detalhada da refeição:
            for (int i = 0; i < lstDados.Count; i++)
            {
                lstDados[i].Id_alimento = i + 1;
            }
            this.DadosalimentosCtrl.lstDadosAlimento.ItemsSource = lstDados;
            #endregion
        }
        /// <summary>
        /// Exibe os pretos de cada tipo de refeição.
        /// </summary>
        public void MostrarPratos()
        {
            atual = MontapratoViewModel.BuscarporIDSemana(
                App.Current.Actives.IdSemena_Select);
            if (atual.Statuspronto)
            {
                //"café da manhã";
                this.Ctrlprato_cafedamanha.imgFrutas.Source =
                    AlimentoViewModel.listarFrutas()[
                        CafedaManhaViewModel.listar()
                        [atual.Cafedamanha_fk - 1].Frutafk - 1].ImgConvertedSource();
                this.Ctrlprato_cafedamanha.imgPaos.Source =
                    AlimentoViewModel.listarPaes()[
                        CafedaManhaViewModel.listar()
                        [atual.Cafedamanha_fk - 1].Paofk - 1].ImgConvertedSource();
                //"lanche da manhã";
                this.Ctrlprato_lanchedamanha.imgFrutas.Source =
                    AlimentoViewModel.listarFrutas()[
                        LanchedaManhaViewModel.listar()
                        [atual.Lanchemanha_fk - 1].Frutafk - 1].ImgConvertedSource();
                this.Ctrlprato_lanchedamanha.imgPaos.Source =
                    AlimentoViewModel.listarPaes()[
                        LanchedaManhaViewModel.listar()
                        [atual.Lanchemanha_fk - 1].Paofk - 1].ImgConvertedSource();
                // "almoço";

                this.Ctrlprato_almoco.imgFrutas.Source =
                    AlimentoViewModel.listarFrutas()[
                        AlmocoViewModel.listar()
                        [atual.Almoco_fk - 1].Frutafk - 1].ImgConvertedSource();
                this.Ctrlprato_almoco.imgGraos.Source = AlimentoViewModel.listarGraoIntegral()[
                    AlmocoViewModel.listar()
                    [atual.Almoco_fk - 1].GraoIntegralfk - 1].ImgConvertedSource();
                this.Ctrlprato_almoco.imgProteinas.Source = AlimentoViewModel.listarProteinas()[
                    AlmocoViewModel.listar()
                    [atual.Almoco_fk - 1].Proteinafk - 1].ImgConvertedSource();
                this.Ctrlprato_almoco.imgVegetais.Source = AlimentoViewModel.listarvegetal()[
                    AlmocoViewModel.listar()
                    [atual.Almoco_fk - 1].Vegetalfk - 1].ImgConvertedSource();
                //"lanche da tarde";

                this.Ctrlprato_lanchedatarde.imgFrutas.Source =
                    AlimentoViewModel.listarFrutas()[
                        LanchedaTardeViewModel.listar()
                        [atual.Lanchetarde_fk - 1].Frutafk - 1].ImgConvertedSource();
                this.Ctrlprato_lanchedatarde.imgPaos.Source =
                    AlimentoViewModel.listarPaes()[
                        LanchedaTardeViewModel.listar()
                        [atual.Lanchetarde_fk - 1].Paofk - 1].ImgConvertedSource();

                //janta

                this.Ctrlprato_janta.imgFrutas.Source = AlimentoViewModel.listarFrutas()[
                    JantaViewModel.listar()
                    [atual.Jantar_fk - 1].Frutafk - 1].ImgConvertedSource();
                this.Ctrlprato_janta.imgGraos.Source = AlimentoViewModel.listarGraoIntegral()[
                    JantaViewModel.listar()
                    [atual.Jantar_fk - 1].GraoIntegralfk - 1].ImgConvertedSource();
                this.Ctrlprato_janta.imgProteinas.Source = AlimentoViewModel.listarProteinas()[
                    JantaViewModel.listar()
                    [atual.Jantar_fk - 1].Proteinafk - 1].ImgConvertedSource();
                this.Ctrlprato_janta.imgVegetais.Source = AlimentoViewModel.listarvegetal()[
                    JantaViewModel.listar()
                    [atual.Jantar_fk - 1].Vegetalfk - 1].ImgConvertedSource();

                //"lanche da noite";

                this.Ctrlprato_lanchedanoite.imgFrutas.Source = AlimentoViewModel.listarFrutas()[
                    LanchedaNoiteViewModel.listar()
                    [atual.Lanchedanoite_fk - 1].Frutafk - 1].ImgConvertedSource();
                this.Ctrlprato_lanchedanoite.imgPaos.Source =
                    AlimentoViewModel.listarPaes()[
                        LanchedaNoiteViewModel.listar()
                        [atual.Lanchedanoite_fk - 1].Paofk - 1].ImgConvertedSource();
            }
        }