Example #1
0
        public ActionResult removevlessons(int Id)
        {
            string Msg = "error";

            VideoL videols = db.VideoLs.Find(Id);

            try
            {
                if (videols != null)
                {
                    if (videols.language == "ru")
                    {
                        VideoXL VideoXl = db.VideoXLs.Find(videols.XId);
                        if (VideoXl.VideoLs.Where(e => e.language != "ru").Count() == 0)
                        {
                            var Tests = videols.Tests.ToList();
                            db.Tests.RemoveRange(Tests);

                            db.VideoLs.Remove(videols);

                            VideoLEM VideoLEMObj = db.VideoLEMs.Where(e => e.VideoXId == videols.XId).First();

                            db.VideoLEMs.Remove(VideoLEMObj);

                            VideoXL VideoXLObj = db.VideoXLs.Where(e => e.XId == videols.XId).First();

                            db.VideoXLs.Remove(VideoXLObj);

                            db.SaveChanges();

                            Msg = "success";
                        }
                    }
                    else
                    {
                        var Tests = videols.Tests.ToList();
                        db.Tests.RemoveRange(Tests);

                        db.VideoLs.Remove(videols);

                        db.SaveChanges();

                        Msg = "success";
                    }
                }
            }
            catch { }



            return(Json(Msg));
        }
Example #2
0
        public ActionResult removemodule(int Id)
        {
            string Msg = "error";

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


            try
            {
                if (Module.VideoLs.Count > 0)
                {
                    foreach (var videols in Module.VideoLs.ToList())
                    {
                        var Tests = videols.Tests.ToList();
                        db.Tests.RemoveRange(Tests);
                        db.VideoLs.Remove(videols);

                        VideoLEM VideoLEMObj = db.VideoLEMs.Where(e => e.VideoXId == videols.XId).First();
                        db.VideoLEMs.Remove(VideoLEMObj);


                        VideoXL VideoXLObj = db.VideoXLs.Where(e => e.XId == videols.XId).First();
                        db.VideoXLs.Remove(VideoXLObj);
                    }
                }


                db.Modul_userLevel.RemoveRange(Module.Modul_userLevel);
                db.Modules_Property.RemoveRange(Module.Modules_Property);
                db.Moduls.Remove(Module);
                db.SaveChanges();
                Msg = "success";
            }
            catch
            {
            }



            return(Json(Msg));
        }
Example #3
0
        // POST: api/Default
        public async Task <IHttpActionResult> Post(string language)
        {
            ResponseVideoLs response = new ResponseVideoLs();

            var EnableVideoLs = new List <VideoL>();

            var UVideoLessons = new List <UVideoLessons>();


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

                string UserName = User.Identity.Name;

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



                JVLO JV = await db.JVLOes.FirstOrDefaultAsync(e => e.UserName == UserName);


                //-----GET User ENABLE VIDEOXLs----------------------------------------
                var Moduls_userLevel = await db.Modul_userLevel.Where(e => e.LevelId <= userinfo.LevelId).ToListAsync();

                var Moduls         = Moduls_userLevel.Select(e => e.Modul).Where(e => e.Enable == true).ToList();
                var EnableVideoXLs = new List <VideoXL>();
                foreach (var Module in Moduls)
                {
                    EnableVideoXLs.AddRange(Module.VideoXLs.Where(e => e.Enable == true).ToList());
                }
                //-----END------------------------------------------------------------



                EnableVideoXLs = EnableVideoXLs.OrderBy(e => e.XId).ToList();


                foreach (var videoXL in EnableVideoXLs)
                {
                    EnableVideoLs.AddRange(videoXL.VideoLs);
                }

                List <VideoL> videoizb = new List <VideoL>();
                foreach (var izb in userinfo.Isbrannis.ToList())
                {
                    VideoL vid = EnableVideoLs.FirstOrDefault(e => e.language == language && e.XId == izb.VideoLXId);
                    if (vid == null)
                    {
                        vid = EnableVideoLs.FirstOrDefault(e => e.language == "ru" && e.XId == izb.VideoLXId);
                    }

                    if (vid != null)
                    {
                        videoizb.Add(vid);
                    }
                }

                foreach (var videoLs in videoizb)
                {
                    string Image = videoLs.Iconimg != null?Url.Content(videoLs.Iconimg) : null;

                    bool Enable = true;
                    int  Like   = 0;
                    int  View   = 0;
                    int  minute = 0;

                    VideoLEM videLem = videoLs.VideoXL.VideoLEMs.FirstOrDefault();

                    if (videLem != null)
                    {
                        Like   = videLem.Likes;
                        View   = videLem.Eye;
                        minute = videLem.minute;
                    }


                    if (JV.X < videoLs.XId)
                    {
                        Image = videoLs.Iconimg != null?Url.Content(videoLs.Iconimg2) : null;

                        Enable = false;
                    }

                    UVideoLessons.Add(new UVideoLessons
                    {
                        Id     = videoLs.Id,
                        MId    = videoLs.Modul.XId,
                        lang   = videoLs.language,
                        Name   = videoLs.Name,
                        Image  = Image,
                        Like   = Like,
                        View   = View,
                        minute = minute,
                        Enable = Enable
                    });
                }

                response.status        = "ok";
                response.UVideoLessons = UVideoLessons;
                return(Json(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IHttpActionResult> Post([FromBody] VideoStaticsCs data)
        {
            try
            {
                string UserName = User.Identity.Name;

                VideoL videols = await db.VideoLs.FindAsync(data.videoId);

                if (videols != null)
                {
                    VideoLEM videolem = videols.VideoXL.VideoLEMs.FirstOrDefault();



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

                    if (data.like == true)
                    {
                        LikeV lkv = userinfo.LikeVs.FirstOrDefault(e => e.VideoXId == videols.XId);

                        if (lkv == null)
                        {
                            videolem.Likes += 1;
                            LikeV newlkv = new LikeV();
                            newlkv.UserId   = userinfo.Id;
                            newlkv.VideoXId = videols.XId;
                            db.LikeVs.Add(newlkv);
                        }
                    }
                    else if (data.like == false)
                    {
                        videolem.Likes -= 1;
                        LikeV lkv = userinfo.LikeVs.FirstOrDefault(e => e.VideoXId == videols.XId);
                        if (lkv != null)
                        {
                            db.LikeVs.Remove(lkv);
                        }
                    }


                    if (data.viewing == true)
                    {
                        EyeV eye = userinfo.EyeVs.FirstOrDefault(e => e.VideoXId == videols.XId);

                        if (eye == null)
                        {
                            videolem.Eye += 1;
                            EyeV eyenew = new EyeV();
                            eyenew.UserId   = userinfo.Id;
                            eyenew.VideoXId = videols.XId;
                            db.EyeVs.Add(eyenew);
                        }
                    }

                    if (data.chosen == true)
                    {
                        Isbranni izb = userinfo.Isbrannis.FirstOrDefault(e => e.VideoLXId == videols.XId);

                        if (izb == null)
                        {
                            Isbranni newizb = new Isbranni();
                            newizb.UserId    = userinfo.Id;
                            newizb.VideoLXId = videols.XId;
                            db.Isbrannis.Add(newizb);
                        }
                    }
                    else if (data.chosen == false)
                    {
                        Isbranni izb = userinfo.Isbrannis.FirstOrDefault(e => e.VideoLXId == videols.XId);
                        if (izb != null)
                        {
                            db.Isbrannis.Remove(izb);
                        }
                    }


                    await db.SaveChangesAsync();

                    return(Ok());
                }

                return(BadRequest("Такого видео-урока нет"));
            }
            catch (Exception ex) {
                return(BadRequest(ex.Message));
            }
        }
Example #5
0
        // POST: api/Default
        public async Task <IHttpActionResult> Post([FromBody] VideoLessonCs data)
        {
            ResponseVideoL response     = new ResponseVideoL();
            UVideoLesson   UVideoLesson = new UVideoLesson();

            try
            {
                string UserName = User.Identity.Name;

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

                JVLO JV = await db.JVLOes.FirstOrDefaultAsync(e => e.UserName == UserName);


                if (data == null)
                {
                    return(BadRequest("data null"));
                }

                if (data.Id == null)
                {
                    return(BadRequest("data id null"));
                }


                VideoL VideoL = await db.VideoLs.FindAsync(data.Id);

                if (VideoL == null)
                {
                    return(BadRequest("VideoL null"));
                }

                if (VideoL.Modul.Enable != true)
                {
                    return(BadRequest("VideoL Disable"));
                }

                if (VideoL.VideoXL.Enable != true)
                {
                    return(BadRequest("VideoL Disable"));
                }

                if (VideoL.Modul.Modul_userLevel.FirstOrDefault().LevelId > userinfo.LevelId)
                {
                    return(BadRequest("User level not available"));
                }

                if (VideoL.XId > JV.X)
                {
                    return(BadRequest("User level not available"));
                }



                //-----GET User ENABLE VIDEOXLs----------------------------------------
                var Moduls_userLevel = await db.Modul_userLevel.Where(e => e.LevelId <= userinfo.LevelId).ToListAsync();

                var Moduls         = Moduls_userLevel.Select(e => e.Modul).Where(e => e.Enable == true).ToList();
                var EnableVideoXLs = new List <VideoXL>();
                foreach (var Module in Moduls)
                {
                    EnableVideoXLs.AddRange(Module.VideoXLs.Where(e => e.Enable == true).ToList());
                }
                //-----END------------------------------------------------------------



                var vxl = EnableVideoXLs.OrderBy(e => e.XId).ToList();


                VideoXL vlXID = vxl.Where(e => e.XId < VideoL.XId).OrderByDescending(e => e.XId).FirstOrDefault();
                VideoXL vnXID = vxl.Where(e => e.XId > VideoL.XId).OrderBy(e => e.XId).FirstOrDefault();

                VideoL vl = null;
                VideoL vn = null;

                if (vlXID != null)
                {
                    vl = await db.VideoLs.FirstOrDefaultAsync(e => e.XId == vlXID.XId && e.language == VideoL.language);

                    if (vl == null && VideoL.language != "ru")
                    {
                        vl = await db.VideoLs.FirstOrDefaultAsync(e => e.XId == vlXID.XId && e.language == "ru");
                    }
                }
                if (vnXID != null)
                {
                    vn = await db.VideoLs.FirstOrDefaultAsync(e => e.XId == vnXID.XId && e.language == VideoL.language);

                    if (vn == null && VideoL.language != "ru")
                    {
                        vn = await db.VideoLs.FirstOrDefaultAsync(e => e.XId == vnXID.XId && e.language == "ru");
                    }
                }



                int  Like = 0;
                int  View = 0;
                bool test = false;
                if (VideoL.Tests.Count > 0)
                {
                    test = true;
                    ValitO valito = userinfo.ValitOS.FirstOrDefault(e => e.VdeoLXId == VideoL.XId);
                    if (valito != null)
                    {
                        if (valito.KB > 74)
                        {
                            test = false;
                        }
                    }
                }


                bool FoolLook = false;

                LessonVideoTime look = userinfo.LessonVideoTimes.FirstOrDefault(e => e.LessonXId == VideoL.XId);
                if (look != null)
                {
                    if (look.Status)
                    {
                        FoolLook = true;
                    }
                }



                bool task = false;

                Models.Task Vtask = await db.Tasks.FirstOrDefaultAsync(e => e.LessonXId == VideoL.XId);

                if (Vtask != null)
                {
                    UserTaskCheck UserTaskCheck = userinfo.UserTaskChecks.FirstOrDefault(e => e.TaskId == Vtask.Id);
                    if (UserTaskCheck != null)
                    {
                        if (UserTaskCheck.Status == false)
                        {
                            task = true;
                        }
                    }
                    else if (FoolLook == true)
                    {
                        task = true;
                        UserTaskCheck newUserTaskCheck = new UserTaskCheck();
                        newUserTaskCheck.TaskId = Vtask.Id;
                        newUserTaskCheck.Status = false;
                        userinfo.UserTaskChecks.Add(newUserTaskCheck);
                        await db.SaveChangesAsync();
                    }
                }



                VideoLEM videLem = VideoL.VideoXL.VideoLEMs.FirstOrDefault();

                if (videLem != null)
                {
                    Like = videLem.Likes;
                    View = videLem.Eye;
                }

                bool certificate = false;

                double LastVXId = vxl.Where(e => e.MId == 4).Max(e => e.XId);

                if (VideoL.XId == LastVXId)
                {
                    if (FoolLook == false)
                    {
                        certificate = true;
                    }
                }



                bool liked  = false;
                bool viewed = false;
                bool chosen = false;
                EyeV eye    = userinfo.EyeVs.FirstOrDefault(e => e.VideoXId == VideoL.XId);
                if (eye != null)
                {
                    viewed = true;
                }
                LikeV like = userinfo.LikeVs.FirstOrDefault(e => e.VideoXId == VideoL.XId);
                if (like != null)
                {
                    liked = true;
                }
                Isbranni isb = userinfo.Isbrannis.FirstOrDefault(e => e.VideoLXId == VideoL.XId);
                if (isb != null)
                {
                    chosen = true;
                }


                if (vl != null)
                {
                    UVideoLesson.previousId = vl.Id;
                }

                if (vn != null)
                {
                    UVideoLesson.nextId = vn.Id;
                }



                UVideoLesson.Id          = VideoL.Id;
                UVideoLesson.lang        = VideoL.language;
                UVideoLesson.Name        = VideoL.Name;
                UVideoLesson.Link        = VideoL.Link;
                UVideoLesson.Like        = Like;
                UVideoLesson.Views       = View;
                UVideoLesson.Liked       = liked;
                UVideoLesson.Viewed      = viewed;
                UVideoLesson.Chosen      = chosen;
                UVideoLesson.FoolLook    = FoolLook;
                UVideoLesson.Test        = test;
                UVideoLesson.Task        = task;
                UVideoLesson.certificate = certificate;

                response.status       = "ok";
                response.UVideoLesson = UVideoLesson;

                return(Json(response));
            }

            catch (Exception ex) {
                return(BadRequest(ex.Message));
            }
        }
Example #6
0
        // POST: api/Default
        public async Task <IHttpActionResult> Post([FromBody] VideoLessonsCs data)
        {
            ResponseVideoLs response = new ResponseVideoLs();

            var EnableVideoLs = new List <VideoL>();

            var UVideoLessons = new List <UVideoLessons>();


            try
            {
                string language = null;
                int?   MId      = null;

                if (data != null)
                {
                    language = data.language;
                    MId      = data.MId;
                }


                if (language == null)
                {
                    language = "ru";
                }

                string UserName = User.Identity.Name;

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



                JVLO JV = await db.JVLOes.FirstOrDefaultAsync(e => e.UserName == UserName);

                var EnableVideoXLs = new List <VideoXL>();



                var Moduls_userLevel = await db.Modul_userLevel.Where(e => e.LevelId <= userinfo.LevelId).ToListAsync();



                var Moduls = Moduls_userLevel.Select(e => e.Modul).Where(e => e.Enable == true).ToList();

                if (MId != null)
                {
                    Moduls = Moduls.Where(e => e.XId == MId).ToList();
                }


                foreach (var Module in Moduls)
                {
                    EnableVideoXLs.AddRange(Module.VideoXLs.Where(e => e.Enable == true).ToList());
                }



                if (EnableVideoXLs.Count > 0)
                {
                    EnableVideoXLs = EnableVideoXLs.OrderBy(e => e.XId).ToList();



                    foreach (var videoXL in EnableVideoXLs)
                    {
                        VideoL addVideoL = videoXL.VideoLs.FirstOrDefault(e => e.language == language);
                        if (language != "ru" && addVideoL == null)
                        {
                            addVideoL = videoXL.VideoLs.FirstOrDefault(e => e.language == "ru");
                        }
                        if (addVideoL != null)
                        {
                            EnableVideoLs.Add(addVideoL);
                        }
                    }

                    foreach (var videoLs in EnableVideoLs)
                    {
                        string Image = videoLs.Iconimg != null?Url.Content(videoLs.Iconimg) : null;

                        bool Enable = true;
                        int  Like   = 0;
                        int  View   = 0;
                        int  minute = 0;

                        VideoLEM videLem = videoLs.VideoXL.VideoLEMs.FirstOrDefault();

                        if (videLem != null)
                        {
                            Like   = videLem.Likes;
                            View   = videLem.Eye;
                            minute = videLem.minute;
                        }


                        if (JV.X < videoLs.XId)
                        {
                            Image = videoLs.Iconimg != null?Url.Content(videoLs.Iconimg2) : null;

                            Enable = false;
                        }


                        string Date = null;
                        string Time = null;
                        if (videoLs.Date != null)
                        {
                            Date = videoLs.Date.Value.ToString("MM/dd/yyyy");
                            Time = videoLs.Date.Value.ToString("HH:mm:ss");
                        }

                        UVideoLessons.Add(new UVideoLessons {
                            Id     = videoLs.Id,
                            MId    = videoLs.Modul.XId,
                            lang   = videoLs.language,
                            Name   = videoLs.Name,
                            Image  = Image,
                            Like   = Like,
                            View   = View,
                            Date   = Date,
                            Time   = Time,
                            minute = minute,
                            Enable = Enable
                        });
                    }
                }

                response.status        = "ok";
                response.UVideoLessons = UVideoLessons;
                return(Json(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #7
0
        public ActionResult editvlessons(VideoL videols, int minute, string language, bool?publish)
        {
            string Msg       = "error";
            VideoL oldVideoL = db.VideoLs.Find(videols.Id);

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


                if (publish == null)
                {
                    publish = false;
                }

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

                    string ImageName = file1.FileName;
                    oldVideoL.Iconimg = "~/Images/Limage/" + language + "/" + 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(oldVideoL.Iconimg));
                }


                HttpPostedFileBase file2 = Request.Files["img2"];
                if (file2.FileName != "" && file2 != null)
                {
                    string fullPath = Request.MapPath(oldVideoL.Iconimg2);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }

                    string ImageName = file2.FileName;
                    oldVideoL.Iconimg2 = "~/Images/Limage/" + language + "/" + DateTime.Now.Date.Year + DateTime.Now.Date.Month + DateTime.Now.Date.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + "_" + ImageName.Replace(" ", "_");
                    file2.SaveAs(HttpContext.Server.MapPath(oldVideoL.Iconimg2));
                }



                oldVideoL.Link           = videols.Link;
                oldVideoL.Name           = videols.Name;
                oldVideoL.VideoXL.Enable = (bool)publish;


                VideoLEM videolem = oldVideoL.VideoXL.VideoLEMs.FirstOrDefault();
                videolem.minute = minute;

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

            var Modules = db.Modules_Property.Where(e => e.lang == "ru").ToList();

            ViewBag.Modules = Modules;

            ViewBag.Message = Msg;

            return(View(oldVideoL));
        }
Example #8
0
        public ActionResult createvlessons(VideoL videols, int minute, string language, string XId, bool?publish)
        {
            if (language == null)
            {
                language = "ru";
            }
            ViewBag.language = language;

            if (publish == null)
            {
                publish = false;
            }

            string Msg = "error";

            try
            {
                videols.XId = Convert.ToDouble(XId.Replace(",", "."));
            }
            catch
            {
                Msg = "warning02";
            }


            HttpPostedFileBase file1 = Request.Files["img1"];

            HttpPostedFileBase file2 = Request.Files["img2"];

            VideoL video = db.VideoLs.Where(e => e.language == language && e.XId == videols.XId).FirstOrDefault();

            if (video == null)
            {
                try
                {
                    if (file1.FileName != "" && file1 != null)
                    {
                        string ImageName = file1.FileName;
                        videols.Iconimg = "~/Images/Limage/" + language + "/" + 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(videols.Iconimg));
                    }

                    if (file2.FileName != "" && file2 != null)
                    {
                        string ImageName = file2.FileName;
                        videols.Iconimg2 = "~/Images/Limage/" + language + "/" + DateTime.Now.Date.Year + DateTime.Now.Date.Month + DateTime.Now.Date.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + "_" + ImageName.Replace(" ", "_");
                        file2.SaveAs(HttpContext.Server.MapPath(videols.Iconimg2));
                    }

                    VideoXL videoXL = db.VideoXLs.Where(e => e.XId == videols.XId).FirstOrDefault();

                    if (videoXL == null)
                    {
                        VideoXL newVideoXL = new VideoXL();
                        newVideoXL.XId    = videols.XId;
                        newVideoXL.MId    = videols.ModulId;
                        newVideoXL.Enable = (bool)publish;
                        db.VideoXLs.Add(newVideoXL);



                        VideoLEM newVideLem = new VideoLEM();
                        newVideLem.Eye      = 0;
                        newVideLem.Likes    = 0;
                        newVideLem.minute   = minute;
                        newVideLem.VideoXId = videols.XId;
                        db.VideoLEMs.Add(newVideLem);
                    }

                    videols.Date = DateTime.Now.AddHours(5);

                    db.VideoLs.Add(videols);
                    db.SaveChanges();
                    Msg = "success";
                }
                catch
                {
                }
            }
            else if (video != null)
            {
                Msg = "warning01";
            }



            if (Msg != "success")
            {
                if (file1.FileName != "" && file1 != null)
                {
                    string fullPath = Request.MapPath(videols.Iconimg);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
                if (file2.FileName != "" && file2 != null)
                {
                    string fullPath = Request.MapPath(videols.Iconimg2);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                }
            }

            var VideoLessons = db.VideoLs.Where(e => e.language == "ru").ToList();
            var Modules      = db.Modules_Property.Where(e => e.lang == "ru").ToList();

            ViewBag.VideoLessons = VideoLessons;
            ViewBag.AddVideoMsg  = Msg;

            return(View(Modules));
        }