public ReplyChildData ReplyChildCreat(ReplyChildData dataObject) { if (dataObject == null) throw new ArgumentNullException("replyChildDataObject"); using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) { var replyChildRepository = context.GetRepository<ReplyChild>(); ReplyChild replyChild = Mapper.Map<ReplyChildData, ReplyChild>(dataObject); replyChild.CreatTime = DateTime.Now; replyChildRepository.Add(replyChild); context.Commit(); return Mapper.Map<ReplyChild, ReplyChildData>(replyChild); } }
public void ReplyChildUpdate(ReplyChildData dataObject) { if (string.IsNullOrEmpty(dataObject.ID)) throw new ArgumentNullException("ID"); ReplyChild replyChild = Mapper.Map<ReplyChildData, ReplyChild>(dataObject); using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) { var replyChildRepository = context.GetRepository<ReplyChild>(); var upInfo = replyChildRepository.Get(Specification<ReplyChild>.Eval(c => c.ID.ToString() == dataObject.ID)); if (!string.IsNullOrEmpty(dataObject.Content)) upInfo.Content = dataObject.Content; if (dataObject.ActEnum != 0) upInfo.ActEnum = dataObject.ActEnum; replyChildRepository.Update(upInfo); } }