public ActionResult Update(Magazines magazineEntity, MagazinesContent magazineContentEntity, HttpPostedFileBase image_tr, HttpPostedFileBase image_en, HttpPostedFileBase image_ru, HttpPostedFileBase pdf_tr, HttpPostedFileBase pdf_en, HttpPostedFileBase pdf_ru)
        {
            BlueprintMediaServisEntity entities = new BlueprintMediaServisEntity();

            var magazineContentTheUpdate = entities.MagazinesContent.Where(w => w.id == magazineContentEntity.id).FirstOrDefault();

            if (image_tr != null)
            {
                string imagePath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image_tr.FileName));
                magazineContentTheUpdate.imageFile_tr = ConvertByte(imagePath, image_tr);
            }
            if (image_en != null)
            {
                string imagePath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image_en.FileName));
                magazineContentTheUpdate.imageFile_en = ConvertByte(imagePath, image_en);
            }
            if (image_ru != null)
            {
                string imagePath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image_ru.FileName));
                magazineContentTheUpdate.imageFile_ru = ConvertByte(imagePath, image_ru);
            }


            if (pdf_tr != null)
            {
                string pdfPath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf_tr.FileName));
                magazineContentTheUpdate.pdfFile_tr = ConvertByte(pdfPath, pdf_tr);
            }
            if (pdf_en != null)
            {
                string pdfPath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf_en.FileName));
                magazineContentTheUpdate.pdfFile_en = ConvertByte(pdfPath, pdf_en);
            }
            if (pdf_ru != null)
            {
                string pdfPath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf_ru.FileName));
                magazineContentTheUpdate.pdfFile_ru = ConvertByte(pdfPath, pdf_ru);
            }


            magazineContentTheUpdate.imageName_tr = magazineContentEntity.imageName_tr;
            magazineContentTheUpdate.imageName_en = magazineContentEntity.imageName_en;
            magazineContentTheUpdate.imageName_ru = magazineContentEntity.imageName_ru;
            magazineContentTheUpdate.pdfName_tr   = magazineContentEntity.pdfName_tr;
            magazineContentTheUpdate.pdfName_en   = magazineContentEntity.pdfName_en;
            magazineContentTheUpdate.pdfName_ru   = magazineContentEntity.pdfName_ru;
            magazineContentTheUpdate.title_tr     = magazineContentEntity.title_tr;
            magazineContentTheUpdate.title_en     = magazineContentEntity.title_en;
            magazineContentTheUpdate.title_ru     = magazineContentEntity.title_ru;
            magazineContentTheUpdate.categoryId   = magazineContentEntity.categoryId;

            magazineContentTheUpdate.updateTime = DateTime.Now;

            entities.SaveChanges();

            Session["status"] = "success";


            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            BlueprintMediaServisEntity entity          = new BlueprintMediaServisEntity();
            MagazinesContent           magazineContent = entity.MagazinesContent.Find(id);


            if (magazineContent != null)
            {
                Magazines magazine = entity.Magazines.Find(magazineContent.magazineId);
                entity.Magazines.Remove(magazine);
                entity.MagazinesContent.Remove(magazineContent);
                entity.SaveChanges();
                Session["status"] = "deleted";
                return(RedirectToAction("Index"));
            }
            else
            {
                Session["status"] = "itemNotFound";
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Insert(Magazines magazineEntity, MagazinesContent magazinesContentEntity, HttpPostedFileBase image_tr, HttpPostedFileBase image_en, HttpPostedFileBase image_ru, HttpPostedFileBase pdf_tr, HttpPostedFileBase pdf_en, HttpPostedFileBase pdf_ru)
        {
            BlueprintMediaServisEntity BMSentity = new BlueprintMediaServisEntity();
            int count = 0;

            if (image_tr != null)
            {
                string imagePath_tr = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image_tr.FileName));
                magazinesContentEntity.imageFile_tr = ConvertByte(imagePath_tr, image_tr);
                count++;
            }

            if (image_en != null)
            {
                string imagePath_en = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image_en.FileName));
                magazinesContentEntity.imageFile_en = ConvertByte(imagePath_en, image_en);
                count++;
            }

            if (image_ru != null)
            {
                string imagePath_ru = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image_ru.FileName));
                magazinesContentEntity.imageFile_ru = ConvertByte(imagePath_ru, image_ru);
                count++;
            }

            if (pdf_tr != null)
            {
                string pdfPath_tr = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf_tr.FileName));
                magazinesContentEntity.pdfFile_tr = ConvertByte(pdfPath_tr, pdf_tr);
                count++;
            }

            if (pdf_en != null)
            {
                string pdfPath_en = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf_en.FileName));
                magazinesContentEntity.pdfFile_en = ConvertByte(pdfPath_en, pdf_en);
                count++;
            }

            if (pdf_ru != null)
            {
                string pdfPath_ru = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf_ru.FileName));
                magazinesContentEntity.pdfFile_ru = ConvertByte(pdfPath_ru, pdf_ru);
                count++;
            }

            if (magazinesContentEntity.title_tr != null)
            {
                count++;
            }
            if (magazinesContentEntity.title_en != null)
            {
                count++;
            }
            if (magazinesContentEntity.title_ru != null)
            {
                count++;
            }

            if (count == 9)
            {
                magazineEntity = new Magazines();

                magazinesContentEntity.updateTime = DateTime.Now;
                magazinesContentEntity.createTime = DateTime.Now;
                magazinesContentEntity.Magazines  = magazineEntity;

                BMSentity.MagazinesContent.Add(magazinesContentEntity);
                BMSentity.Magazines.Add(magazineEntity);
                BMSentity.SaveChanges();
                Session["status"] = "success";
            }
            else if (count == 8)
            {
                magazineEntity = new Magazines();

                magazinesContentEntity.updateTime = DateTime.Now;
                magazinesContentEntity.createTime = DateTime.Now;
                magazinesContentEntity.Magazines  = magazineEntity;

                BMSentity.MagazinesContent.Add(magazinesContentEntity);
                BMSentity.Magazines.Add(magazineEntity);
                BMSentity.SaveChanges();
                Session["status"] = "missing";
            }
            else
            {
                Session["status"] = "failed";
            }

            return(RedirectToAction("Index"));
        }