Ejemplo n.º 1
0
        public ActionResult removevlessons(int Id)
        {
            string Msg = "error";

            Training_VideoL videols = db.Training_VideoL.Find(Id);

            try
            {
                if (videols != null)
                {
                    if (videols.language == "ru")
                    {
                        Training_VideoXL VideoXl = db.Training_VideoXL.Find(videols.XId);
                        if (VideoXl.Training_VideoL.Where(e => e.language != "ru").Count() == 0)
                        {
                            db.Training_VideoL.Remove(videols);

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

                            db.Training_VideoLEM.Remove(VideoLEMObj);

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

                            db.Training_VideoXL.Remove(VideoXLObj);

                            db.SaveChanges();

                            Msg = "success";
                        }
                    }
                    else
                    {
                        db.Training_VideoL.Remove(videols);

                        db.SaveChanges();

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



            return(Json(Msg));
        }
Ejemplo n.º 2
0
        public ActionResult removemodule(int Id)
        {
            string Msg = "error";

            Training Training = db.Trainings.Find(Id);


            try
            {
                if (Training.Training_VideoL.Count > 0)
                {
                    foreach (var videols in Training.Training_VideoL.ToList())
                    {
                        Training_VideoLEM VideoLEMObj = db.Training_VideoLEM.Where(e => e.VideoXId == videols.XId).First();
                        db.Training_VideoLEM.Remove(VideoLEMObj);


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



                db.Training_Property.RemoveRange(Training.Training_Property);
                db.Trainings.Remove(Training);
                db.SaveChanges();
                Msg = "success";
            }
            catch
            {
            }



            return(Json(Msg));
        }
Ejemplo n.º 3
0
        public ActionResult createvlessons(Training_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"];

            Training_VideoL video = db.Training_VideoL.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/Training/" + 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/Training/" + 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));
                    }

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

                    if (videoXL == null)
                    {
                        Training_VideoXL newVideoXL = new Training_VideoXL();
                        newVideoXL.XId    = videols.XId;
                        newVideoXL.TrId   = videols.TrId;
                        newVideoXL.Enable = (bool)publish;
                        db.Training_VideoXL.Add(newVideoXL);



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

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

                    db.Training_VideoL.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.Training_VideoL.Where(e => e.language == "ru").ToList();
            var Modules      = db.Training_Property.Where(e => e.lang == "ru").ToList();

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

            return(View(Modules));
        }
Ejemplo n.º 4
0
        // POST: api/Default
        public async Task <IHttpActionResult> Post([FromBody] Training_VideoLessonCs data)
        {
            ResponseUTraining_VideoL response             = new ResponseUTraining_VideoL();
            UTraining_VideoLesson    Training_VideoLesson = new UTraining_VideoLesson();

            try
            {
                string UserName = User.Identity.Name;

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

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

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


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

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

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

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

                int Like = 0;
                int View = 0;


                Training_VideoLEM videLem = VideoL.Training_VideoXL.Training_VideoLEM.FirstOrDefault();

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

                bool liked  = false;
                bool viewed = false;

                Training_EyeV eye = userinfo.Training_EyeV.FirstOrDefault(e => e.VideoXId == VideoL.XId);
                if (eye != null)
                {
                    viewed = true;
                }
                Training_LikeV like = userinfo.Training_LikeV.FirstOrDefault(e => e.VideoXId == VideoL.XId);
                if (like != null)
                {
                    liked = true;
                }



                Training_VideoXL vlXID = await db.Training_VideoXL.Where(e => e.XId < VideoL.XId).OrderByDescending(e => e.XId).FirstOrDefaultAsync();

                Training_VideoXL vnXID = await db.Training_VideoXL.Where(e => e.XId > VideoL.XId).OrderBy(e => e.XId).FirstOrDefaultAsync();

                Training_VideoL vl = null;
                Training_VideoL vn = null;

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

                    if (vl != null)
                    {
                        Training_VideoLesson.previousId = vl.Id;
                    }
                }
                if (vnXID != null)
                {
                    vn = await db.Training_VideoL.FirstOrDefaultAsync(e => e.XId == vnXID.XId && e.language == VideoL.language);

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


                Training_VideoLesson.Id     = VideoL.Id;
                Training_VideoLesson.lang   = VideoL.language;
                Training_VideoLesson.Name   = VideoL.Name;
                Training_VideoLesson.Link   = VideoL.Link;
                Training_VideoLesson.Like   = Like;
                Training_VideoLesson.View   = View;
                Training_VideoLesson.Liked  = liked;
                Training_VideoLesson.Viewed = viewed;



                response.status = "ok";

                response.Training_VideoLesson = Training_VideoLesson;

                return(Json(response));
            }

            catch (Exception ex) {
                return(BadRequest(ex.Message));
            }
        }