/// <summary> /// Model转Entity /// </summary> /// <param name="model"></param> /// <returns></returns> private HR_DICTIONARY ModelToEntity(HrDictionary model) { if (model != null) { var entity = new HR_DICTIONARY() { DICTIONARYID = model.DictionaryId, FATHERID = model.FatherId, DICTIONCATEGORY = model.DictionCategory, DICTIONARYNAME = model.DictionaryName, DICTIONARYVALUE = model.DictionaryValue, CREATEUSER = model.CreateUser, CREATEDATE = model.CreateDate, UPDATEUSER = model.UpdateUser, UPDATEDATE = model.UpdateDate, DICTIONCATEGORYNAME = model.DictionCategoryName, REMARK = model.Remark, SYSTEMNAME = model.SystemName, SYSTEMCODE = model.SystemCode, ORDERNUMBER = model.OrderNumber, SYSTEMNEED = model.SystemNeed, ISDELETED = model.IsDeleted }; return(entity); } return(null); }
/// <summary> /// Entity转Model /// </summary> /// <param name="entity"></param> /// <returns></returns> private HrDictionary EntityToModel(HR_DICTIONARY entity) { if (entity != null) { var model = new HrDictionary() { DictionaryId = entity.DICTIONARYID, FatherId = entity.FATHERID, DictionCategory = entity.DICTIONCATEGORY, DictionaryName = entity.DICTIONARYNAME, DictionaryValue = entity.DICTIONARYVALUE, CreateUser = entity.CREATEUSER, CreateDate = entity.CREATEDATE, UpdateUser = entity.UPDATEUSER, UpdateDate = entity.UPDATEDATE, DictionCategoryName = entity.DICTIONCATEGORYNAME, Remark = entity.REMARK, SystemName = entity.SYSTEMNAME, SystemCode = entity.SYSTEMCODE, OrderNumber = entity.ORDERNUMBER, SystemNeed = entity.SYSTEMNEED, IsDeleted = entity.ISDELETED }; return(model); } return(null); }
public IHttpActionResult Delete(string Id) { if (string.IsNullOrEmpty(Id)) { return(BadRequest("非法请求!")); } try { HrDictionary model = bll.GetOne(p => p.DICTIONARYID.Equals(Id)); if (model == null) { return(Ok("ok")); } model.IsDeleted = true; bll.Edit(model); return(Ok("ok")); } catch (Exception ex) { LogService.WriteErrorLog("DictionaryManageController[Delete]", ex.ToString()); return(BadRequest("异常!")); } }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> private bool Update(HrDictionary model) { UserInfo currentUser = new UserInfoService().GetCurrentUser(); string userName = currentUser == null ? "" : currentUser.LoginName; model.UpdateDate = DateTime.Now; model.UpdateUser = userName; return(bll.Edit(model)); }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Edit(HrDictionary model) { if (model == null) { return(false); } using (DictionaryDAL dal = new DictionaryDAL()) { HR_DICTIONARY entitys = ModelToEntity(model); return(dal.Edit(entitys)); } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public string Add(HrDictionary model) { if (model == null) { return(string.Empty); } using (DictionaryDAL dal = new DictionaryDAL()) { HR_DICTIONARY entity = ModelToEntity(model); entity.DICTIONARYID = string.IsNullOrEmpty(model.DictionaryId) ? Guid.NewGuid().ToString() : model.DictionaryId; return(dal.Add(entity)); } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> private bool Insert(HrDictionary model) { UserInfo currentUser = new UserInfoService().GetCurrentUser(); string userName = currentUser == null ? "" : currentUser.LoginName; model.CreateDate = DateTime.Now; model.CreateUser = userName; model.SystemNeed = "0"; if (string.IsNullOrEmpty(bll.Add(model))) { return(false); } return(true); }
public IHttpActionResult Get(string Id) { try { HrDictionary model = bll.GetOne(p => p.DICTIONARYID.Equals(Id)); if (model != null) { HrDictionary father = bll.GetOne(p => p.DICTIONARYID.Equals(model.FatherId)); model.FatherId = string.Format("{0}#{1}", father.DictionaryId, father.DictionaryName); } return(Ok(model)); } catch (Exception ex) { LogService.WriteErrorLog("DictionaryManageController[Get]", ex.ToString()); return(BadRequest("异常!")); } }
public IHttpActionResult Post([FromBody] Request <HrDictionary> request) { try { HrDictionary model = request.Data; bool result = true; if (string.IsNullOrEmpty(model.DictionaryId)) { result = Insert(model); } else { result = Update(model); } return(Ok(result == true?"ok":"false")); } catch (Exception ex) { LogService.WriteErrorLog("DictionaryManageController[Post]", ex.ToString()); return(BadRequest(ex.ToString())); } }