Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Post([FromBody] TasktendreamCs data)
        {
            //if (data.VideoLessonId == null)
            //{
            //    return BadRequest("VideoLessonId not specified");
            //}

            try
            {
                string UserName = User.Identity.Name;

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

                Task_First tasktendream = userinfo.Task_First.FirstOrDefault();

                if (tasktendream != null)
                {
                    tasktendream.First  = data.First;
                    tasktendream.Second = data.Second;
                    tasktendream.Third  = data.Third;
                    tasktendream.Four   = data.Fourth;
                    tasktendream.Five   = data.Fifth;
                    tasktendream.Six    = data.Sixth;
                    tasktendream.Seven  = data.Seventh;
                    tasktendream.Eight  = data.Eighth;
                    tasktendream.Nine   = data.Ninth;
                    tasktendream.Ten    = data.Tenth;
                }
                else
                {
                    Task_First usertasktendream = new Task_First();

                    usertasktendream.First  = data.First;
                    usertasktendream.Second = data.Second;
                    usertasktendream.Third  = data.Third;
                    usertasktendream.Four   = data.Fourth;
                    usertasktendream.Five   = data.Fifth;
                    usertasktendream.Six    = data.Sixth;
                    usertasktendream.Seven  = data.Seventh;
                    usertasktendream.Eight  = data.Eighth;
                    usertasktendream.Nine   = data.Ninth;
                    usertasktendream.Ten    = data.Tenth;

                    userinfo.Task_First.Add(usertasktendream);
                }

                db.SaveChanges();

                UserTaskCheck ustskch       = userinfo.UserTaskChecks.FirstOrDefault(e => e.TaskId == 34);
                UserTaskCheck UserTaskCheck = new UserTaskCheck();

                if (ustskch == null)
                {
                    UserTaskCheck.TaskId = 34;
                    UserTaskCheck.Status = false;
                }


                if (!string.IsNullOrEmpty(data.First) && !string.IsNullOrEmpty(data.Second) &&
                    !string.IsNullOrEmpty(data.Third) && !string.IsNullOrEmpty(data.Fourth) &&
                    !string.IsNullOrEmpty(data.Fifth) && !string.IsNullOrEmpty(data.Sixth) &&
                    !string.IsNullOrEmpty(data.Seventh) && !string.IsNullOrEmpty(data.Eighth) &&
                    !string.IsNullOrEmpty(data.Ninth) && !string.IsNullOrEmpty(data.Tenth))
                {
                    if (ustskch == null)
                    {
                        UserTaskCheck.Status = true;
                        userinfo.UserTaskChecks.Add(UserTaskCheck);
                    }
                    else
                    {
                        ustskch.Status = true;
                    }

                    VideoL VideoL = await db.VideoLs.FirstOrDefaultAsync(e => e.XId == 3 && e.language == "ru");

                    var test = VideoL.Tests.ToList();

                    if (test.Count == 0)
                    {
                        JVLO jv = await db.JVLOes.FirstOrDefaultAsync(e => e.UserName == UserName);

                        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());
                        }

                        VideoXL NextVideoXL = EnableVideoXLs.Where(e => e.XId > 3).OrderBy(e => e.XId).FirstOrDefault();



                        if (NextVideoXL != null)
                        {
                            if (NextVideoXL.XId > jv.X)
                            {
                                jv.X = NextVideoXL.XId;
                            }
                        }
                    }
                }



                await db.SaveChangesAsync();

                return(Ok());
            }
            catch
            {
                return(BadRequest("filed"));
            }
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> Get(string language)
        {
            if (language == null)
            {
                language = "ru";
            }

            ResponseUTasks response = new ResponseUTasks();



            var UTasks = new List <UTasks>();

            response.status = "filed";
            response.Tasks  = UTasks;

            try
            {
                string UserName = User.Identity.Name;

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

                var tasks = await db.Tasks.ToListAsync();

                string TaskTenDream = "";

                switch (language)
                {
                case "kz":

                    TaskTenDream = "Осы бизнесте қол жеткізгіңіз келетін 10 арман туралы жазыңыз.";
                    break;

                case "ru":
                    TaskTenDream = "Запишите 10 ваших конкретных мечты, которые Вы хотите достичь в этом бизнесе.";
                    break;

                case "uz":
                    TaskTenDream = "Ushbu biznesda erishmoqchi bo'lgan aniq 10 ta orzularingizni yozing.";
                    break;

                case "kr":
                    TaskTenDream = "Ушул бизнесте өзүңүз каалаган 10 кыялыңызга жазыңыз.";
                    break;

                case "tr":
                    TaskTenDream = "Bu işte başarmak istediğiniz 10 hayalinizi yazın.";
                    break;

                case "en":
                    TaskTenDream = "Write down 10 of your specific dreams that you want to achieve in this business.";
                    break;
                }


                foreach (var task in tasks)
                {
                    UserTaskCheck usertask = userinfo.UserTaskChecks.FirstOrDefault(e => e.TaskId == task.Id);

                    VideoL VideoL = await db.VideoLs.FirstOrDefaultAsync(e => e.XId == task.LessonXId && e.language == language);

                    if (usertask != null)
                    {
                        UTasks.Add(new UTasks
                        {
                            Id            = task.Id,
                            VideoLessonId = VideoL.Id,
                            Task          = TaskTenDream
                        });
                    }
                }

                response.status = "Ok";
                response.Tasks  = UTasks;
                return(Json(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
0
        // POST: api/Default
        public async Task <IHttpActionResult> Post([FromBody] UVideoLcompletionCs data)
        {
            ResponseUVideoLcompletion response = new ResponseUVideoLcompletion();

            if (data == null)
            {
                return(BadRequest("data null"));
            }
            if (data.VideoId == null || (data.TestTotal == null && data.FoolLook == null))
            {
                return(BadRequest("data null"));
            }

            VideoL video = await db.VideoLs.FindAsync(data.VideoId);

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

            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);

                bool LookVideo = true;
                bool Task      = true;
                bool Test      = true;

                LessonVideoTime look = userinfo.LessonVideoTimes.FirstOrDefault(e => e.LessonXId == video.XId);

                if (data.FoolLook == true)
                {
                    if (look == null)
                    {
                        LessonVideoTime newlook = new LessonVideoTime();
                        newlook.LessonXId = video.XId;
                        newlook.Status    = true;
                        userinfo.LessonVideoTimes.Add(newlook);
                        await db.SaveChangesAsync();
                    }
                    else if (look.Status == false)
                    {
                        look.Status = true;
                        await db.SaveChangesAsync();
                    }

                    response.msgfoollook = "ok";
                }

                if (look != null)
                {
                    if (look.Status == false)
                    {
                        LookVideo = false;
                    }
                }


                Models.Task task = await db.Tasks.FirstOrDefaultAsync(e => e.LessonXId == video.XId);

                if (task != null)
                {
                    UserTaskCheck UserTaskCheck = userinfo.UserTaskChecks.FirstOrDefault(e => e.TaskId == task.Id);
                    if (UserTaskCheck != null)
                    {
                        if (UserTaskCheck.Status == false)
                        {
                            Task = false;
                        }
                    }
                }



                var test = video.Tests.ToList();


                if (test.Count() > 0)
                {
                    if (Task == false)
                    {
                        response.msgtesttotal = "Task not completed";
                        Test = false;
                    }

                    if (LookVideo == false)
                    {
                        response.msgtesttotal = "Video not fully viewed";
                        Test = false;
                    }
                }


                if (test.Count() > 0 && Test == true)
                {
                    ValitO vo = userinfo.ValitOS.FirstOrDefault(e => e.VdeoLXId == video.XId);

                    int KB = vo != null ? vo.KB : 0;


                    if (data.TestTotal != null)
                    {
                        if (data.TestTotal > 0)
                        {
                            if (vo == null)
                            {
                                KB = (int)data.TestTotal;

                                ValitO newvo = new ValitO();
                                newvo.VdeoLXId = video.XId;
                                newvo.KB       = KB;
                                userinfo.ValitOS.Add(newvo);

                                await db.SaveChangesAsync();
                            }
                            else if (vo.KB < data.TestTotal)
                            {
                                KB    = (int)data.TestTotal;
                                vo.KB = KB;
                                await db.SaveChangesAsync();
                            }

                            response.msgtesttotal = "ok";
                        }
                    }

                    if (KB < 75)
                    {
                        Test = false;
                    }
                }



                if (LookVideo == true && Task == true && Test == true)
                {
                    //-----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 NextVideoXL = EnableVideoXLs.Where(e => e.XId > video.XId).OrderBy(e => e.XId).FirstOrDefault();


                    VideoXL vnXID = vxl.Where(e => e.XId > video.XId).OrderBy(e => e.XId).FirstOrDefault();


                    VideoL vn = null;


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

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

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

                    if (NextVideoXL != null)
                    {
                        if (NextVideoXL.XId > JV.X)
                        {
                            JV.X = NextVideoXL.XId;
                            await db.SaveChangesAsync();
                        }
                    }
                }
                response.status = "ok";
                return(Json(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }