public string SaveClass(string jsonString, string action) { try { ClassInfoEntity entity = JsonConvert.DeserializeObject <ClassInfoEntity>(jsonString); ClassInfoManager manager = new ClassInfoManager(); if (action == "add") { manager.Insert(entity); } else { ClassInfoEntity oldEntity = manager.GetClassInfoByCode(entity.Code); oldEntity.Name = entity.Name; oldEntity.Type = entity.Type; oldEntity.StartTime = entity.StartTime; oldEntity.EndTime = entity.EndTime; oldEntity.TeacherID = entity.TeacherID; oldEntity.UpdateBy = SessionHelper.CurrentUser.Code; manager.Update(oldEntity); } return("success"); } catch (Exception e) { return(e.ToString()); } }
public string GetClassInfoByCode(string code) { ClassInfoManager manager = new ClassInfoManager(); return(new JavaScriptSerializer().Serialize(manager.GetClassInfoByCode(code))); }