/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Edit(V_xy_sp_chapter model) { if (model == null) { return(false); } using (xy_sp_chapterDAL dal = new xy_sp_chapterDAL()){ xy_sp_chapter entitys = ModelToEntity(model); return(dal.Edit(entitys)); } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public string Add(V_xy_sp_chapter model) { if (model == null) { return(string.Empty); } using (xy_sp_chapterDAL dal = new xy_sp_chapterDAL()){ xy_sp_chapter entity = ModelToEntity(model); entity.chapterID = string.IsNullOrEmpty(model.chapterID) ? Guid.NewGuid().ToString("N") : model.chapterID; return(dal.Add(entity)); } }
public IHttpActionResult Post([FromBody] Request <V_xy_sp_chapter> request) { V_xy_sp_chapter model = request.Data as V_xy_sp_chapter; if (string.IsNullOrEmpty(model.chapterID)) { bll.Add(model); } else { bll.Edit(model); } return(Ok("ok")); }
/// <summary> /// Model转Entity /// </summary> /// <param name="model"></param> /// <returns></returns> private xy_sp_chapter ModelToEntity(V_xy_sp_chapter model) { if (model != null) { xy_sp_chapter entity = new xy_sp_chapter() { chapterID = model.chapterID, chapterName = model.chapterName, chapterDescript = model.chapterDescript, AddrID = model.AddrID, }; return(entity); } return(null); }
/// <summary> /// Entity转Model /// </summary> /// <param name="entity"></param> /// <returns></returns> private V_xy_sp_chapter EntityToModel(xy_sp_chapter entity) { if (entity != null) { V_xy_sp_chapter model = new V_xy_sp_chapter() { chapterID = entity.chapterID, chapterName = entity.chapterName, chapterDescript = entity.chapterDescript, AddrID = entity.AddrID, }; return(model); } return(null); }
public IHttpActionResult Get(string ID) { V_xy_sp_chapter model = bll.Get(p => p.chapterID == ID); return(Ok(model)); }