Esempio n. 1
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. 2
0
        public async Task <IHttpActionResult> Post([FromBody] ModulCs data)
        {
            ResponseUModuls response = new ResponseUModuls();

            try
            {
                if (data == null)
                {
                    data = new ModulCs()
                    {
                        language = "ru"
                    };
                }

                string UserName = User.Identity.Name;

                UserInfo userinfo = await db.UserInfoes.FirstOrDefaultAsync(e => e.UserName == UserName);



                var ModulObj = await db.Moduls.Where(e => e.Enable == true).OrderBy(e => e.XId).ToListAsync();

                var UModulesObj = new List <UModuls>();

                foreach (var module in ModulObj)
                {
                    Modules_Property ModulesP = module.Modules_Property.FirstOrDefault(e => e.lang == data.language);
                    if (ModulesP == null)
                    {
                        ModulesP = module.Modules_Property.FirstOrDefault(e => e.lang == "ru");
                    }

                    if (ModulesP != null)
                    {
                        Modul_userLevel ModulesUL = module.Modul_userLevel.FirstOrDefault();


                        UModuls newUModules = new UModuls();
                        newUModules.Id   = module.XId;
                        newUModules.Name = ModulesP.Titile;

                        newUModules.Image = Url.Content(module.Image);
                        newUModules.lang  = ModulesP.lang;

                        bool Enable = true;

                        if (ModulesUL.LevelId > userinfo.LevelId)
                        {
                            Enable = false;
                        }

                        newUModules.Enable = Enable;


                        UModulesObj.Add(newUModules);
                    }
                }

                Users_Certificates UserCertificate = userinfo.Users_Certificates.FirstOrDefault(e => e.PublicCert == true && e.TypeCert == 3);


                response.status         = "ok";
                response.certificateURL = UserCertificate != null?Url.Content(UserCertificate.CertificateURL) : null;

                response.UModuls = UModulesObj;

                return(Json(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 3
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));
        }