Ejemplo n.º 1
0
 public ModelsViewModel Get(int?id)
 {
     using (var db = new SmartAutosContext())
     {
         return(ModelDto.ModelViewModelDTO(db.Model.FirstOrDefault(x => x.Id == id)));
     }
 }
Ejemplo n.º 2
0
        public List <ModelsViewModel> GetAll()
        {
            List <ModelsViewModel> models = new List <ModelsViewModel>();

            using (var db = new SmartAutosContext())
            {
                foreach (var item in db.Model.Select(x => x).ToList())
                {
                    models.Add(ModelDto.ModelViewModelDTO(item));
                }
            }

            return(models);
        }
Ejemplo n.º 3
0
        public List <ModelsViewModel> GetFor(int?manufacturerId)
        {
            if (manufacturerId == null)
            {
                return(GetAll());
            }
            else
            {
                List <ModelsViewModel> models = new List <ModelsViewModel>();
                using (var db = new SmartAutosContext())
                {
                    foreach (var item in db.Model.Where(x => x.ManufacturerId == manufacturerId).ToList())
                    {
                        models.Add(ModelDto.ModelViewModelDTO(item));
                    }
                }

                return(models);
            }
        }