Esempio n. 1
0
        public ActionResult editModule(ModuleCs newModule, string language)
        {
            if (language == null)
            {
                language = "ru";
            }
            ViewBag.language = language;

            string Msg = "error";

            Modul editModule = db.Moduls.Find(newModule.ModuleId);

            try
            {
                newModule.Image = editModule.Image;

                HttpPostedFileBase file1 = Request.Files["img1"];
                if (file1.FileName != "" && file1 != null)
                {
                    string fullPath = Request.MapPath(editModule.Image);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }

                    string ImageName = file1.FileName;
                    editModule.Image = "~/Images/ModulImage/" + DateTime.Now.Date.Year + DateTime.Now.Date.Month + DateTime.Now.Date.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + "_" + ImageName.Replace(" ", "_");
                    newModule.Image  = editModule.Image;
                    file1.SaveAs(HttpContext.Server.MapPath(editModule.Image));
                }

                Modules_Property Modules_PKZ = editModule.Modules_Property.Where(e => e.lang == "kz").FirstOrDefault();
                if (Modules_PKZ != null)
                {
                    Modules_PKZ.Titile = newModule.NameKZ;
                }
                else
                {
                    Modules_Property newModules_PKZ = new Modules_Property();
                    newModules_PKZ.lang   = "kz";
                    newModules_PKZ.Titile = newModule.NameKZ;
                    editModule.Modules_Property.Add(newModules_PKZ);
                }


                Modules_Property Modules_PRU = editModule.Modules_Property.Where(e => e.lang == "ru").FirstOrDefault();
                if (Modules_PRU != null)
                {
                    Modules_PRU.Titile = newModule.NameRU;
                }

                Modules_Property Modules_PUZ = editModule.Modules_Property.Where(e => e.lang == "uz").FirstOrDefault();
                if (Modules_PUZ != null)
                {
                    Modules_PUZ.Titile = newModule.NameUZ;
                }
                else
                {
                    Modules_Property newModules_PUZ = new Modules_Property();
                    newModules_PUZ.lang   = "uz";
                    newModules_PUZ.Titile = newModule.NameUZ;
                    editModule.Modules_Property.Add(newModules_PUZ);
                }

                Modules_Property Modules_PKR = editModule.Modules_Property.Where(e => e.lang == "kr").FirstOrDefault();
                if (Modules_PKR != null)
                {
                    Modules_PKR.Titile = newModule.NameKR;
                }
                else
                {
                    Modules_Property newModules_PKR = new Modules_Property();
                    newModules_PKR.lang   = "kr";
                    newModules_PKR.Titile = newModule.NameKR;
                    editModule.Modules_Property.Add(newModules_PKR);
                }

                Modules_Property Modules_PEN = editModule.Modules_Property.Where(e => e.lang == "en").FirstOrDefault();
                if (Modules_PEN != null)
                {
                    Modules_PEN.Titile = newModule.NameEN;
                }
                else
                {
                    Modules_Property newModules_PEN = new Modules_Property();
                    newModules_PEN.lang   = "en";
                    newModules_PEN.Titile = newModule.NameEN;
                    editModule.Modules_Property.Add(newModules_PEN);
                }


                Modules_Property Modules_PTR = editModule.Modules_Property.Where(e => e.lang == "tr").FirstOrDefault();
                if (Modules_PTR != null)
                {
                    Modules_PTR.Titile = newModule.NameTR;
                }
                else
                {
                    Modules_Property newModules_PTR = new Modules_Property();
                    newModules_PTR.lang   = "tr";
                    newModules_PTR.Titile = newModule.NameTR;
                    editModule.Modules_Property.Add(newModules_PTR);
                }


                Modul_userLevel Modul_level = editModule.Modul_userLevel.FirstOrDefault();
                Modul_level.LevelId = newModule.LevelId;
                editModule.Enable   = newModule.publish;
                editModule.XId      = newModule.XId;

                db.SaveChanges();
                Msg = "success";
                ViewBag.EditModuleMsg = Msg;
            }
            catch { }


            return(View(newModule));
        }
Esempio n. 2
0
        public ActionResult createModule(ModuleCs newModule, string language)
        {
            if (language == null)
            {
                language = "ru";
            }
            ViewBag.language = language;


            string Msg = "error";

            Modul createModule = new Modul();


            try
            {
                HttpPostedFileBase file1 = Request.Files["img1"];
                if (file1.FileName != "" && file1 != null)
                {
                    string ImageName = file1.FileName;
                    createModule.Image = "~/Images/ModulImage/" + DateTime.Now.Date.Year + DateTime.Now.Date.Month + DateTime.Now.Date.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + "_" + ImageName.Replace(" ", "_");
                    file1.SaveAs(HttpContext.Server.MapPath(createModule.Image));
                }



                Modules_Property Modules_PRU = new Modules_Property();
                Modules_PRU.lang   = "ru";
                Modules_PRU.Titile = newModule.NameRU;
                createModule.Modules_Property.Add(Modules_PRU);

                if (newModule.NameKZ != null)
                {
                    Modules_Property Modules_PKZ = new Modules_Property();
                    Modules_PKZ.lang   = "kz";
                    Modules_PKZ.Titile = newModule.NameKZ;
                    createModule.Modules_Property.Add(Modules_PKZ);
                }



                if (newModule.NameUZ != null)
                {
                    Modules_Property Modules_PUZ = new Modules_Property();
                    Modules_PUZ.lang   = "uz";
                    Modules_PUZ.Titile = newModule.NameUZ;
                    createModule.Modules_Property.Add(Modules_PUZ);
                }

                if (newModule.NameKR != null)
                {
                    Modules_Property Modules_PKR = new Modules_Property();
                    Modules_PKR.lang   = "kr";
                    Modules_PKR.Titile = newModule.NameKR;
                    createModule.Modules_Property.Add(Modules_PKR);
                }

                if (newModule.NameEN != null)
                {
                    Modules_Property Modules_PEN = new Modules_Property();
                    Modules_PEN.lang   = "en";
                    Modules_PEN.Titile = newModule.NameEN;
                    createModule.Modules_Property.Add(Modules_PEN);
                }


                if (newModule.NameTR != null)
                {
                    Modules_Property Modules_PTR = new Modules_Property();
                    Modules_PTR.lang   = "tr";
                    Modules_PTR.Titile = newModule.NameTR;
                    createModule.Modules_Property.Add(Modules_PTR);
                }


                Modul_userLevel Modul_level = new Modul_userLevel();
                Modul_level.LevelId = newModule.LevelId;

                createModule.Modul_userLevel.Add(Modul_level);


                createModule.Enable = newModule.publish;

                createModule.XId = newModule.XId;

                db.Moduls.Add(createModule);
                db.SaveChanges();
                Msg = "success";
            }
            catch { }
            ViewBag.AddModuleMsg = Msg;

            return(View());
        }
Esempio n. 3
0
        //: EDITMODULE ---------------------------------------------------------------------------
        public ActionResult editModule(int Id, string language)
        {
            if (language == null)
            {
                language = "ru";
            }

            Modul Module = db.Moduls.Find(Id);

            ViewBag.language = language;

            ModuleCs ModuleCs = new ModuleCs();

            ModuleCs.ModuleId = Id;
            ModuleCs.LevelId  = Module.Modul_userLevel.FirstOrDefault().LevelId;

            Modules_Property Modules_PKZ = Module.Modules_Property.Where(e => e.lang == "kz").FirstOrDefault();

            if (Modules_PKZ != null)
            {
                ModuleCs.NameKZ = Modules_PKZ.Titile;
            }



            Modules_Property Modules_PRU = Module.Modules_Property.Where(e => e.lang == "ru").FirstOrDefault();

            if (Modules_PRU != null)
            {
                ModuleCs.NameRU = Modules_PRU.Titile;
            }

            Modules_Property Modules_PUZ = Module.Modules_Property.Where(e => e.lang == "uz").FirstOrDefault();

            if (Modules_PUZ != null)
            {
                ModuleCs.NameUZ = Modules_PUZ.Titile;
            }

            Modules_Property Modules_PKR = Module.Modules_Property.Where(e => e.lang == "kr").FirstOrDefault();

            if (Modules_PKR != null)
            {
                ModuleCs.NameKR = Modules_PKR.Titile;
            }

            Modules_Property Modules_PEN = Module.Modules_Property.Where(e => e.lang == "en").FirstOrDefault();

            if (Modules_PEN != null)
            {
                ModuleCs.NameEN = Modules_PEN.Titile;
            }

            Modules_Property Modules_PTR = Module.Modules_Property.Where(e => e.lang == "tr").FirstOrDefault();

            if (Modules_PTR != null)
            {
                ModuleCs.NameTR = Modules_PTR.Titile;
            }

            ModuleCs.Image   = Module.Image;
            ModuleCs.publish = Module.Enable;
            ModuleCs.XId     = Module.XId;

            return(View(ModuleCs));
        }