public JsonResult Add(NotificationModel model) { long id_gv = long.Parse(Session["UserId"].ToString()); model.TeacherID = id_gv; var tt = practiceService.GetByLoaiTTvaHocKy(model.PracticeID, model.SemesterID); model.PracticeTypeID = tt.ID; var student = StudentService.getListByTeacherIdAndPracticeId(id_gv, tt.ID); var m = new Notification { TeacherID = model.TeacherID, PracticeTypeID = model.PracticeTypeID, Title = model.Title, Content = model.Content, CreateBy = model.TeacherID }; bool status = notification.Create(m); var nt = notification.returnId(); foreach (var st in student) { StudentNotificationRelationship s = new StudentNotificationRelationship(); s.StudentID = st.ID; s.NotificationID = nt; studentNotification.Create(s); } return(Json(status, JsonRequestBehavior.AllowGet)); }
public bool Update(StudentNotificationRelationship model) { try { if (model == null) { return(false); } var update = studentNotificationDAL.Update(model); return(update); } catch { return(false); } }
public bool Create(StudentNotificationRelationship model) { try { //Initialization empty item var item = new StudentNotificationRelationship(); //Set value for item with value from model item.StudentID = model.StudentID; item.NotificationID = model.NotificationID; item.Status = false; //Add item to entity context.StudentNotificationRelationships.Add(item); //Save to database context.SaveChanges(); return(true); } catch { return(false); } }
public bool Update(StudentNotificationRelationship model) { try { //Get item user with Id from database var item = context.StudentNotificationRelationships.Where(i => i.ID == model.ID).FirstOrDefault(); //Set value item with value from model item.StudentID = model.StudentID; item.NotificationID = model.NotificationID; //Save change to database context.SaveChanges(); return(true); } catch { return(false); } }