Example #1
0
        public bool Create(TopicStudent model)
        {
            try
            {
                //Initialization empty item
                var item = new TopicStudent();

                //Set value for item with value from model
                item.TopicID           = model.TopicID;
                item.StudentPracticeID = model.StudentPracticeID;
                item.Order             = model.Order;
                item.CreateBy          = model.CreateBy;
                item.CreateTime        = DateTime.Now;
                item.Progress          = 0;

                //Add item to entity
                context.TopicStudents.Add(item);
                //Save to database
                context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
 public bool Create(TopicStudent model)
 {
     try
     {
         if (model == null)
         {
             return(false);
         }
         var create = topicStudentDAL.Create(model);
         return(create);
     }
     catch
     {
         return(false);
     }
 }
Example #3
0
 public bool Update(TopicStudent model)
 {
     try
     {
         if (model == null)
         {
             return(false);
         }
         var update = topicStudentDAL.Update(model);
         return(update);
     }
     catch
     {
         return(false);
     }
 }
Example #4
0
 public JsonResult Add(List <TopicStudentModel> list)
 {
     foreach (TopicStudentModel topicStudent in list)
     {
         long id_student = long.Parse(Session["UserId"].ToString());
         var  sinhvienTT = sinhVienTTService.GetBySinhVienvaLoaiTT(id_student, topicStudent.SemesterID);
         topicStudent.StudentPracticeID = sinhvienTT.ID;
         var m = new TopicStudent
         {
             StudentPracticeID = topicStudent.StudentPracticeID,
             TopicID           = topicStudent.TopicID,
             Order             = topicStudent.Order,
             CreateBy          = topicStudent.CreateBy,
             CreateTime        = topicStudent.CreateTime,
         };
         topicStudentService.Create(m);
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Example #5
0
        public bool Update(TopicStudent model)
        {
            try
            {
                //Get item user with Id from database
                var item = context.TopicStudents.Where(i => i.ID == model.ID).FirstOrDefault();

                //Set value item with value from model
                item.Status = model.Status;

                item.ModifiedBy   = model.ModifiedBy;
                item.ModifiedTime = DateTime.Now;

                //Save change to database
                context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }