Ejemplo n.º 1
0
        /// <summary>
        /// Save Student quiz result in database
        /// </summary>
        /// <param name="result">quiz result</param>
        /// <returns>true/false</returns>
        public bool SaveQuizResult(int result, int TotalMarks)
        {
            try
            {
                QuizDetail quizDetail = new QuizDetail();
                quizDetail.Id          = Guid.NewGuid();
                quizDetail.UserId      = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());
                quizDetail.QuizId      = Guid.NewGuid();
                quizDetail.Result      = result;
                quizDetail.TotalMarks  = TotalMarks;
                quizDetail.Status      = true;
                quizDetail.DateCreated = DateTime.Now;
                quizDetail.IsActive    = true;

                using (var db = new MyLearnDBEntitiess())
                {
                    db.QuizDetails.Add(quizDetail);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Call when user use Editor Activity
        /// </summary>
        /// <param name="courseDetailId"></param>
        /// <returns></returns>
        public bool Update_Student_Course_Activity(Guid courseDetailId)
        {
            try
            {
                var UserId = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());

                using (var db = new MyLearnDBEntitiess())
                {
                    var _result = db.CourseDetails.SingleOrDefault(b => b.CourseId == courseDetailId && b.UserId == UserId);
                    if (_result != null)
                    {
                        _result.StatusTotal  = _result.StatusTotal + 1;
                        _result.LastAccessed = DateTime.Now;
                        _result.DateEdited   = DateTime.Now;

                        db.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public ActionResult Create([Bind(Include = "Id,GroupName,CreatedBy,CourseID,CreatedDate,DateEdited,IsEnable,IsActive")] GroupMaster groupMaster)
        {
            if (groupMaster.GroupName != "")
            {
                string userId = User.Identity.GetUserId();
                groupMaster.Id          = Guid.NewGuid();
                groupMaster.CreatedBy   = Guid.Parse(userId);
                groupMaster.CreatedDate = DateTime.Now;
                groupMaster.CourseID    = Guid.Parse("3E851245-056E-40BA-8767-5C662F0D0C86");
                groupMaster.DateEdited  = DateTime.Now;
                groupMaster.IsActive    = true;
                groupMaster.IsEnable    = true;

                db.GroupMasters.Add(groupMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Error = "Ok";
            return(View(groupMaster));
        }
Ejemplo n.º 4
0
 public void AddLog_Quiz(string _userId)
 {
     using (var db = new MyLearnDBEntitiess())
     {
         var _result = db.UserLogs.SingleOrDefault(b => b.UserID == _userId);
         if (_result != null)
         {
             _result.Quiz = DateTime.Now;
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Add new Long data
        /// </summary>
        /// <param name="_userId"></param>
        public void Add_Log(string _userId)
        {
            UserLog userlog = new UserLog();

            userlog.Id               = Guid.NewGuid();
            userlog.UserID           = _userId;
            userlog.Login            = DateTime.Now;
            userlog.Quiz             = null;
            userlog.ActivityAccessed = null;

            using (var db = new MyLearnDBEntitiess())
            {
                db.UserLogs.Add(userlog);
                db.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        //public List<QuizDetail> GetQuizDetailsById(string user_id)
        //{
        //    var dbcon = new SqlConnection(ConfigurationManager.ConnectionStrings["_MyLearnDBEntities"].ToString());
        //    var dbcommand = new SqlCommand();
        //    dbcommand.Connection = dbcon;
        //    dbcommand.CommandText = "select * from QuizDetail where UserId = @user_id";
        //    dbcon.Open();
        //    var model = new List<QuizDetail>();
        //    var reader = dbcommand.ExecuteReader();
        //    while (reader.Read())
        //    {
        //        var details = new QuizDetail();
        //        details.Result = int.Parse(reader["Result"].ToString());
        //        details.TotalMarks = int.Parse(reader["TotalMarks"].ToString());

        //    }
        //    dbcon.Close();
        //    return model;
        //}

        public void UpdateUser(string user, string email, int number, string user_id)
        {
            using (var db = new MyLearnDBEntitiess())
            {
                var        Ids        = Guid.Parse(user_id);
                AspNetUser aspNetUser = new AspNetUser();
                aspNetUser = db.AspNetUsers.SingleOrDefault(x => x.Id == user_id);

                aspNetUser.UserName    = user;
                aspNetUser.Email       = email;
                aspNetUser.PhoneNumber = number.ToString();
                db.SaveChanges();
            }


            return;
        }
Ejemplo n.º 7
0
        public bool SaveUserPreff(string Color)
        {
            try
            {
                using (var db = new MyLearnDBEntitiess())
                {
                    var Id   = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());
                    var user = db.UserPreferenceMasters.SingleOrDefault(x => x.UserID == Id);
                    user.ThemeColor = Color;
                    db.SaveChanges();

                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Update user into database
        /// </summary>
        /// <param name="result">Update user data</param>
        /// <returns>true/false</returns>
        //public bool UpdateUser(string UserName,string Email, int PhoneNumber )
        //{
        //    try
        //    {
        //        AspNetUser info = new AspNetUser();
        //        info.UserName = UserName;
        //        info.Email = Email;
        //        info.PhoneNumber = int.Parse(PhoneNumber.ToString());
        //        using (var db = new MyLearnDBEntities())
        //        {
        //            db.A.Add(UpdateUser);
        //            db.SaveChanges();
        //        }

        //        return true;

        //    }
        //    catch (Exception)
        //    {

        //        return false;
        //    }
        //}

        /// <summary>
        /// call when student add course
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="CourseId"></param>
        /// <returns></returns>
        public bool Add_Student_Course()
        {
            try
            {
                var courseId = "3E851245-056E-40BA-8767-5C662F0D0C86";
                var UserID   = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());
                using (var db = new MyLearnDBEntitiess())
                {
                    var existUser = db.CourseDetails.SingleOrDefault(x => x.UserId == UserID);
                    if (existUser.Id != null)
                    {
                        return(true);
                    }
                }

                CourseDetail detail = new CourseDetail();

                detail.Id             = Guid.NewGuid();
                detail.UserId         = UserID;
                detail.DateAdded      = DateTime.Now;
                detail.CourseId       = Guid.Parse(courseId);
                detail.ProgressStatus = 0;
                detail.StatusTotal    = 0;
                detail.LastAccessed   = DateTime.Now;
                detail.DateCreated    = DateTime.Now;
                detail.DateEdited     = DateTime.Now;
                detail.IsEnable       = true;
                detail.IsActive       = true;

                using (var db = new MyLearnDBEntitiess())
                {
                    db.CourseDetails.Add(detail);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Join group for students
        /// </summary>
        /// <param name="GroupID"></param>
        public void JoinStudentGroup(Guid GroupID)
        {
            using (var db = new MyLearnDBEntitiess())
            {
                var UserId = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());
                var x      = db.GroupDetails.SingleOrDefault(v => v.UserId == UserId && v.GroupId == GroupID);
                if (x == null)
                {
                    GroupDetail group = new GroupDetail();
                    group.Id          = Guid.NewGuid();
                    group.UserId      = UserId;
                    group.GroupId     = GroupID;
                    group.DateCreated = DateTime.Now;
                    group.DateEdited  = DateTime.Now;
                    group.IsEnable    = true;
                    group.IsActive    = true;

                    db.GroupDetails.Add(group);
                    db.SaveChanges();
                }
            }
        }
Ejemplo n.º 10
0
 public void AddLog_Login(string _userId)
 {
     try
     {
         using (var db = new MyLearnDBEntitiess())
         {
             var _result = db.UserLogs.SingleOrDefault(b => b.UserID == _userId);
             if (_result != null)
             {
                 _result.Login = DateTime.Now;
                 db.SaveChanges();
             }
             else
             {
                 Add_Log(_userId);
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
        public bool Add_Announcement(Announcement Model)
        {
            try
            {
                Model.DateCreated = DateTime.Now;
                Model.IsEnable    = true;
                Model.IsActive    = true;
                Model.Id          = Guid.NewGuid();

                using (var db = new MyLearnDBEntitiess())
                {
                    db.Announcements.Add(Model);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }