public bool Insert(T_RoomType obj) { if (_dal.Insert(obj)) { this.GetAll(); return(true); } else { return(false); } }
// POST: api/RoomType public void Post([FromBody] T_RoomType room) { ServiceObject obj = new ServiceObject(); try { if (!_bll.Insert(room)) { obj.State = ServiceState.error; obj.Msg = "未能插入数据"; } } catch (Exception ex) { obj.State = ServiceState.error; obj.Msg = ex.Message; } }
/// <summary> /// 新增 /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool Insert(T_RoomType obj) { using (XPMSEntities db = new XPMSEntities()) { var query = from a in db.T_RoomType where a.Name.Equals(obj.Name) select a; if (query.Count() > 0) { throw new Exception("该名称已存在"); } var model = db.T_RoomType.Add(obj); if (model == null) { return(false); } else { return(true); } } }
// PUT: api/RoomType/5 public void Put(int id, [FromBody] T_RoomType value) { }