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 PostClassInfo(ClassInfoEntity entity) { try { if (entity == null) { return("error"); } ClassInfoManager manager = new ClassInfoManager(); entity.CreateTime = DateTime.Now; entity.CreateTime = DateTime.Now; manager.Insert(entity); return("success"); } catch (Exception e) { return(e.ToString()); } }