public void InfoUpdate(InfoData dataObject) { if (string.IsNullOrEmpty(dataObject.ID)) throw new ArgumentNullException("ID"); Info info = Mapper.Map<InfoData, Info>(dataObject); using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) { var infoRepository = context.GetRepository<Info>(); var upInfo = infoRepository.Get(Specification<Info>.Eval(c => c.ID.ToString() == dataObject.ID)); if (!string.IsNullOrEmpty(dataObject.Title)) upInfo.Title = dataObject.Title; if (!string.IsNullOrEmpty(dataObject.ContentRich)) upInfo.ContentRich = dataObject.ContentRich; if (dataObject.EndTime.HasValue) upInfo.EndTime = dataObject.EndTime; if (dataObject.StartTime.HasValue) upInfo.EndTime = dataObject.StartTime; if (!string.IsNullOrEmpty(dataObject.LinkUrl)) upInfo.LinkUrl = dataObject.LinkUrl; if (!string.IsNullOrEmpty(dataObject.LinkImage)) upInfo.LinkImage = dataObject.LinkImage; if (dataObject.GradeAverage != 0) upInfo.GradeAverage = dataObject.GradeAverage; if (dataObject.ActEnum != 0) upInfo.ActEnum = dataObject.ActEnum; infoRepository.Update(upInfo); } }
public void InfoUpdate(InfoData dataObject) { try { infoService.InfoUpdate(dataObject); } catch(Exception ex) { ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType); Log.Error(ex); throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex)); } }
public InfoData InfoSubmit(InfoData subInfo, Boolean force) { try { return infoService.InfoSubmit(subInfo, force); } catch(Exception ex) { ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType); Log.Error(ex); throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex)); } }
public InfoData InfoSubmit(InfoData dataObject, bool force) { if (dataObject == null) throw new ArgumentNullException("infoDataObject"); using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) { IRepository<Info> infoRepository = context.GetRepository<Info>(); Info info = Mapper.Map<InfoData, Info>(dataObject); info.CreatTime = DateTime.Now; info.ActEnum = force ? (int)eAct.Normal : (int)eAct.unApproved; infoRepository.Add(info); context.Commit(); return Mapper.Map<Info, InfoData>(info); } }