public ActionResult Save(long id, long?dip, string reason, int points, int type) { var usr = repository.GetUser(id); var d = new students_discipline(); if (dip.HasValue) { d = repository.GetDiscipline(dip.Value); } d.reason = reason; d.type = type; var conduct = db.conducts.Single(x => x.id == type); if (!conduct.isdemerit) { // merit d.points = Math.Abs(points); } else { // demerit d.points = -Math.Abs(points); } if (!dip.HasValue) { d.created = DateTime.Now; d.creator = sessionid.Value; usr.students_disciplines.Add(d); } usr.updated = DateTime.Now; try { repository.Save(); } catch (Exception ex) { return(SendJsonErrorResponse(ex)); } return(Json("Discipline entry saved".ToJsonOKMessage())); }
public void DeleteDiscipline(students_discipline discipline) { db.students_disciplines.DeleteOnSubmit(discipline); }