Пример #1
0
        public Entry Record(Entry a)
        {
            Entry_info info = db.Info.First(x1 => x1.Id == a.Info1_id);
            Entry_img  img  = db.Images.First(x1 => x1.Id == a.Images_id);

            try
            {
                if (info.info_1 != null)
                {
                    a.Info1.Add(info.info_1);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_2 != null)
                {
                    a.Info1.Add(info.info_2);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_3 != null)
                {
                    a.Info1.Add(info.info_3);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_4 != null)
                {
                    a.Info1.Add(info.info_4);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_5 != null)
                {
                    a.Info1.Add(info.info_5);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_6 != null)
                {
                    a.Info1.Add(info.info_6);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_7 != null)
                {
                    a.Info1.Add(info.info_7);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_8 != null)
                {
                    a.Info1.Add(info.info_8);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_9 != null)
                {
                    a.Info1.Add(info.info_9);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_10 != null)
                {
                    a.Info1.Add(info.info_10);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch
            {
            }
            info = db.Info.First(x1 => x1.Id == a.Info2_id);

            try
            {
                if (info.info_1 != null)
                {
                    a.Info2.Add(info.info_1);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_2 != null)
                {
                    a.Info2.Add(info.info_2);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_3 != null)
                {
                    a.Info2.Add(info.info_3);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_4 != null)
                {
                    a.Info2.Add(info.info_4);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_5 != null)
                {
                    a.Info2.Add(info.info_5);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_6 != null)
                {
                    a.Info2.Add(info.info_6);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_7 != null)
                {
                    a.Info2.Add(info.info_7);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_8 != null)
                {
                    a.Info2.Add(info.info_8);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_9 != null)
                {
                    a.Info2.Add(info.info_9);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_10 != null)
                {
                    a.Info2.Add(info.info_10);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch
            {
            }
            info = db.Info.First(x1 => x1.Id == a.Info3_id);

            try
            {
                if (info.info_1 != null)
                {
                    a.Info3.Add(info.info_1);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_2 != null)
                {
                    a.Info3.Add(info.info_2);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_3 != null)
                {
                    a.Info3.Add(info.info_3);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_4 != null)
                {
                    a.Info3.Add(info.info_4);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_5 != null)
                {
                    a.Info3.Add(info.info_5);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_6 != null)
                {
                    a.Info3.Add(info.info_6);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_7 != null)
                {
                    a.Info3.Add(info.info_7);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_8 != null)
                {
                    a.Info3.Add(info.info_8);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_9 != null)
                {
                    a.Info3.Add(info.info_9);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_10 != null)
                {
                    a.Info3.Add(info.info_10);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch
            {
            }
            info = db.Info.First(x1 => x1.Id == a.Info4_id);

            try
            {
                if (info.info_1 != null)
                {
                    a.Info4.Add(info.info_1);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_2 != null)
                {
                    a.Info4.Add(info.info_2);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_3 != null)
                {
                    a.Info4.Add(info.info_3);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_4 != null)
                {
                    a.Info4.Add(info.info_4);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_5 != null)
                {
                    a.Info4.Add(info.info_5);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_6 != null)
                {
                    a.Info4.Add(info.info_6);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_7 != null)
                {
                    a.Info4.Add(info.info_7);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_8 != null)
                {
                    a.Info4.Add(info.info_8);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_9 != null)
                {
                    a.Info4.Add(info.info_9);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (info.info_10 != null)
                {
                    a.Info4.Add(info.info_10);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch
            {
            }



            try
            {
                if (img.s_1 != null)
                {
                    a.Images.Add(img.s_1);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_2 != null)
                {
                    a.Images.Add(img.s_2);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_3 != null)
                {
                    a.Images.Add(img.s_3);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_4 != null)
                {
                    a.Images.Add(img.s_4);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_5 != null)
                {
                    a.Images.Add(img.s_5);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_6 != null)
                {
                    a.Images.Add(img.s_6);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_7 != null)
                {
                    a.Images.Add(img.s_7);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_8 != null)
                {
                    a.Images.Add(img.s_8);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_9 != null)
                {
                    a.Images.Add(img.s_9);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.s_10 != null)
                {
                    a.Images.Add(img.s_10);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch
            {
            }
            try
            {
                if (img.b_1 != null)
                {
                    a.Images_byte.Add(img.b_1);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_2 != null)
                {
                    a.Images_byte.Add(img.b_2);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_3 != null)
                {
                    a.Images_byte.Add(img.b_3);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_4 != null)
                {
                    a.Images_byte.Add(img.b_4);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_5 != null)
                {
                    a.Images_byte.Add(img.b_5);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_6 != null)
                {
                    a.Images_byte.Add(img.b_6);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_7 != null)
                {
                    a.Images_byte.Add(img.b_7);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_8 != null)
                {
                    a.Images_byte.Add(img.b_8);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_9 != null)
                {
                    a.Images_byte.Add(img.b_9);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
                if (img.b_10 != null)
                {
                    a.Images_byte.Add(img.b_10);
                }
                else
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch
            {
            }



            return(a);
        }
Пример #2
0
        public ActionResult Ad_img_add_ad(HttpPostedFileBase[] uploadImage, string obg = null)
        {
            //TODO сейчас не работает и ничего не делает нужно в теории для обработки фоток которые загружаются

            //@Html.Hidden(Model.Images_byte,i)
            irr.Models.Entry res = new Entry();
            Entry_img        img = new Entry_img();

            if (obg != null)
            {
                res = JsonConvert.DeserializeObject <Entry>(obg);
            }
            if (uploadImage != null) //ModelState.IsValid &&
            {
                foreach (var i in uploadImage)
                {
                    try
                    {
                        byte[] imageData = null;
                        // считываем переданный файл в массив байтов
                        using (var binaryReader = new BinaryReader(i.InputStream))
                        {
                            imageData = binaryReader.ReadBytes(i.ContentLength);
                        }
                        // установка массива байтов
                        res.Images_byte.Add(imageData);



                        //return RedirectToAction("Add_new_ad", res);
                    }
                    catch
                    {
                    }
                }



                try
                {
                    img.b_1  = res.Images_byte[0];
                    img.b_2  = res.Images_byte[1];
                    img.b_3  = res.Images_byte[2];
                    img.b_4  = res.Images_byte[3];
                    img.b_5  = res.Images_byte[4];
                    img.b_6  = res.Images_byte[5];
                    img.b_7  = res.Images_byte[6];
                    img.b_8  = res.Images_byte[7];
                    img.b_9  = res.Images_byte[8];
                    img.b_10 = res.Images_byte[9];
                }
                catch
                {
                }
                finally
                {
                    db.Images.Add(img);
                    db.SaveChanges();
                }
                res.Images_id = img.Id;
            }
            return(View("Show_one_ad", res));
        }