コード例 #1
0
ファイル: UserRepository.cs プロジェクト: NamCkiku/do-an-4
 /// <summary>
 /// Cập nhật người dùng
 /// </summary>
 /// <param name="us">User</param>
 /// <returns>bool</returns>
 public bool UpdateUser(StudyOnline.Entities.Models.User us)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         try
         {
             var c = _db.User.Find(us.ID);
             c.UserName     = us.UserName;
             c.Password     = us.Password;
             c.Name         = us.Name;
             c.Address      = us.Address;
             c.Email        = us.Email;
             c.Phone        = us.Phone;
             c.Avatar       = us.Avatar;
             c.Status       = us.Status;
             c.CreatedDate  = us.CreatedDate;
             c.CreatedBy    = us.CreatedBy;
             c.ModifiedDate = us.ModifiedDate;
             c.ModifiedBy   = us.ModifiedBy;
             //c.GroupID = us.GroupID;
             //c.PayID = us.PayID;
             _db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
コード例 #2
0
ファイル: CourseRepository.cs プロジェクト: NamCkiku/do-an-4
 //Cập nhật khóa học
 /// <summary>
 /// Cập Nhật Khóa Học
 /// </summary>
 /// <param name="course">Course</param>
 /// <returns>bool</returns>
 public bool editCourse(StudyOnline.Entities.Models.Course course)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         try
         {
             var c = _db.Course.Find(course.ID);
             c.CourseName       = course.CourseName;
             c.Avatar           = course.Avatar;
             c.VideoIntroduce   = course.VideoIntroduce;
             c.Description      = course.Description;
             c.Content          = course.Content;
             c.PriceSale        = course.PriceSale;
             c.Price            = course.Price;
             c.ViewCount        = course.ViewCount;
             c.CreateDate       = course.CreateDate;
             c.Tags             = course.Tags;
             c.Status           = course.Status;
             c.TopHot           = course.TopHot;
             c.MetaTitle        = course.MetaTitle;
             c.CourseCategoryID = course.CourseCategoryID;
             _db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
コード例 #3
0
ファイル: UserRepository.cs プロジェクト: NamCkiku/do-an-4
 /// <summary>
 /// Tạo người dùng
 /// </summary>
 /// <param name="tq">User</param>
 /// <returns>long</returns>
 public long CreateUser(StudyOnline.Entities.Models.User tq)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         try
         {
             //User data = new User();
             //data.UserName = tq.UserName;
             //data.Name = tq.Name;
             //data.Address = tq.Address;
             //data.Email = tq.Email;
             //data.Phone = tq.Phone;
             //data.Avatar = tq.Avatar;
             //data.Password = Encryptor.MD5Hash(tq.Password);
             //data.Status = false;
             _db.User.Add(tq);
             _db.SaveChanges();
             return(tq.ID);
         }
         catch (Exception)
         {
             return(-1);
         }
     }
 }
コード例 #4
0
ファイル: UserRepository.cs プロジェクト: NamCkiku/do-an-4
 public void Active(int id, bool status)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         var data = _db.User.SingleOrDefault(x => x.ID == id);
         data.Status = true;
         _db.SaveChanges();
     }
 }
コード例 #5
0
 public ActionResult GetPassword(User model)
 {
     if (ModelState.IsValid)
     {
         //var data = db.User.Where(x => x.UserName == model.UserName && x.Email == model.Email).ToList();
         if (userService.CheckEmail(model.Email) && userService.CheckUserName(model.UserName))
         {
             var newpass    = SendMail.RandomString(6);
             var dataUpdate = db.User.SingleOrDefault(x => x.UserName == model.UserName);
             dataUpdate.Password = newpass;
             db.SaveChanges();
             SendMail.SendGmail("Lay lai mat khau", "Mat khau moi cua ban la: " + newpass, "*****@*****.**", " chuvanquan96", model.Email, "*****@*****.**");
             ViewBag.Message = "Mật khẩu đã được gửi đến hòm thư của bạn !";
         }
         else
         {
             ViewBag.Message = "Opps...! Tài khoản hoặc email không tồn tại.";
         }
     }
     return(View("Login"));
 }
コード例 #6
0
ファイル: UserRepository.cs プロジェクト: NamCkiku/do-an-4
 public bool Signup(User user)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         if (user != null)
         {
             var User = _db.User.Add(user);
             _db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #7
0
ファイル: CourseRepository.cs プロジェクト: NamCkiku/do-an-4
 /// <summary>
 /// Tạo 1 khóa học
 /// </summary>
 /// <param name="course">Course</param>
 /// <returns>long</returns>
 public long addCourse(StudyOnline.Entities.Models.Course course)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         try
         {
             _db.Course.Add(course);
             _db.SaveChanges();
             return(course.ID);
         }
         catch (Exception)
         {
             return(-1);
         }
     }
 }
コード例 #8
0
ファイル: UserRepository.cs プロジェクト: NamCkiku/do-an-4
 /// <summary>
 /// Xóa người dùng
 /// </summary>
 /// <param name="id">ID</param>
 /// <returns>bool</returns>
 public bool DeleteUser(long id)
 {
     using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline())
     {
         try
         {
             var result = _db.User.Find(id);
             _db.User.Remove(result);
             _db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }