Пример #1
0
        static void Main(string[] args)
        {
            var _db = new DatabaseContext();
            var bitMapToSave = new BitmapImage();

            foreach (var var in _db.DbSetRecipes)
            {
                if (var.RecipeImage != null)
                {
                    Console.WriteLine("Getting image from id {0}", var.RecipeId);
                    var value = var.RecipeImage;

                    byte[] image = value;
                    MemoryStream ms = new MemoryStream(image);
                    try
                    {
                        Image i = Image.FromStream(ms);
                        string path1 = "c:\\Images\\";
                        string path2 = var.RecipeId.ToString() + ".jpeg";
                        string localFilePath = Path.Combine(path1, path2);
                        i.Save(localFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                        Console.WriteLine("Saved: {0}", localFilePath);
                    }
                    catch (ArgumentException)
                    {
                        Console.WriteLine("Invalid image on {0}", var.RecipeId);
                    }
                   
                }

            }
        }
Пример #2
0
            public Recipe GetRecent([QueryString("RecipeId")] int? recipeId)
        {

            var _db = new DatabaseContext();
                Recipe query = (from x in _db.DbSetRecipes orderby x.AddedTime descending select x).First();

            return query;
        }
Пример #3
0
        //private void BindListView()
        //{
        //    throw new NotImplementedException();
        //}

        public IEnumerable<Recipe> GetRecipes([QueryString("RecipeId")] int? recipeId)
        {

            var _db = new DatabaseContext();
            IEnumerable<Recipe> query = _db.DbSetRecipes.Where(x => x.RecipeId >= 1250 && x.RecipeId < 1280);

            return query;
        }
 public IEnumerable<Ingredient> GetIngredients([QueryString("recipeID")] int? recipeId)
 {
     var _db = new DatabaseContext();
     IEnumerable<Ingredient> query =
         (from x in _db.DbSetRecipes where x.RecipeId == recipeId select x.Ingredients).First();
     
     return query;
 }
Пример #5
0
        // GET: Image
        public async Task<ActionResult> RenderImage(int id)
        {
            var db = new DatabaseContext();
            Recipe item = db.DbSetRecipes.Find(id);

            byte[] photoBack = item.RecipeImage;

            return File(photoBack, "image/png");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var _db = new DatabaseContext();


            if (!String.IsNullOrEmpty(Request.QueryString["RecipeName"]))
            {
                string param = Request.QueryString["RecipeName"];
                seachResult =
                    (from x in _db.DbSetRecipes.AsEnumerable() where (x.RecipeName.ToLower().Contains(param.ToLower())) select x);                  
            }
        }
 public IQueryable<Recipe> GetRecipe([QueryString("recipeID")] int? recipeId)
 {
     var _db = new DatabaseContext();
     IQueryable<Recipe> query = _db.DbSetRecipes;
     if (recipeId.HasValue && recipeId > 0)
     {
         query = query.Where(p => p.RecipeId == recipeId);
     }
     else
     {
         query = null;
     }
     return query;
 }
Пример #8
0
        //private void BindListView()
        //{
        //    throw new NotImplementedException();
        //}

        public IEnumerable<Recipe> GetRecipes([QueryString("id")] int? recipeId)
        {
            
            var _db = new DatabaseContext();
            IEnumerable<Recipe> query = _db.DbSetRecipes.Where(x => x.RecipeId >= 10 && x.RecipeId < 30);

            recipeImage1
            //if (recipeId.HasValue && recipeId > 9)
            //{
            //    query = query.Where(p => p.RecipeId == recipeId);
            //}



            return query;
        }