Exemplo n.º 1
0
        public static AgendaComponenteViewModel MapToListViewModel(AgendaComponente agendaComponente)
        {
            AgendaComponenteViewModel agendaComponenteViewModel = new AgendaComponenteViewModel();

            if (agendaComponente != null && agendaComponente.IdAgendaComponente != 0)
            {
                agendaComponenteViewModel = new AgendaComponenteViewModel()
                {
                    IdAgendaComponente = agendaComponente.IdAgendaComponente,
                    IdComponente       = agendaComponente.IdComponente,
                    IdUnidade          = agendaComponente.IdUnidade,
                    DataIniView        = agendaComponente.DataIni == null ? "" : agendaComponente.DataIni.Value.ToShortDateString(),
                    DataFimView        = agendaComponente.DataFim == null ? "" : agendaComponente.DataFim.Value.ToShortDateString(),
                    HoraIniView        = agendaComponente.HoraIni == null ? "" : agendaComponente.HoraIni.Value.ToShortTimeString(),
                    HoraFimView        = agendaComponente.HoraFim == null ? "" : agendaComponente.HoraFim.Value.ToShortTimeString(),
                    STDefinir          = agendaComponente.STDefinir,
                    DiasSemana         = agendaComponente.DiasSemana.Replace("0", "Domingo")
                                         .Replace("1", "Segunda")
                                         .Replace("2", "Terca")
                                         .Replace("3", "Quarta")
                                         .Replace("4", "Quinta")
                                         .Replace("5", "Sexta")
                                         .Replace("6", "Sabado").Replace(",", "").Replace(" ", "").Replace("/", ""),
                };
            }
            return(agendaComponenteViewModel);
        }
Exemplo n.º 2
0
        //public List<DiasSemanaEnum> ListDiasSemana { get{
        //    List<DiasSemanaEnum> dias = new List<DiasSemanaEnum>();
        //    dias.Add(DiasSemanaEnum.Domingo);
        //    dias.Add(DiasSemanaEnum.Segunda);
        //    dias.Add(DiasSemanaEnum.Terca);
        //    dias.Add(DiasSemanaEnum.Quarta);
        //    dias.Add(DiasSemanaEnum.Quinta);
        //    dias.Add(DiasSemanaEnum.Sexta);
        //    dias.Add(DiasSemanaEnum.Sabado);
        // return dias ;
        //} set; }

        #endregion

        #region Métodos

        public static AgendaComponente MapToModel(AgendaComponenteViewModel agendaComponenteViewModel)
        {
            AgendaComponente agendaComponente = new AgendaComponente()
            {
                IdAgendaComponente = agendaComponenteViewModel.IdAgendaComponente,
                IdComponente       = agendaComponenteViewModel.IdComponente,
                IdUnidade          = agendaComponenteViewModel.IdUnidade,
                DataIni            = DateTime.Parse(agendaComponenteViewModel.DataIniView),
                DataFim            = DateTime.Parse(agendaComponenteViewModel.DataFimView),
                HoraIni            = DateTime.Parse(agendaComponenteViewModel.HoraIniView),
                HoraFim            = DateTime.Parse(agendaComponenteViewModel.HoraFimView),
                STDefinir          = agendaComponenteViewModel.STDefinir,
                DiasSemana         = agendaComponenteViewModel.DiasSemana,
            };

            return(agendaComponente);
        }