public void ProductUpdate(ProductData dataObject) { if (string.IsNullOrEmpty(dataObject.ID)) throw new ArgumentNullException("ID"); Product product = Mapper.Map<ProductData, Product>(dataObject); using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) { var productRepository = context.GetRepository<Product>(); var upInfo = productRepository.Get(Specification<Product>.Eval(c => c.ID.ToString() == dataObject.ID)); if (!string.IsNullOrEmpty(dataObject.Name)) upInfo.Name = dataObject.Name; if (!string.IsNullOrEmpty(dataObject.Link)) upInfo.Link = dataObject.Link; if (!string.IsNullOrEmpty(dataObject.PriceHistoryLink)) upInfo.PriceHistoryLink = dataObject.PriceHistoryLink; if (!string.IsNullOrEmpty(dataObject.PriceHistory)) upInfo.PriceHistory = dataObject.PriceHistory; if (!string.IsNullOrEmpty(dataObject.Image)) upInfo.Image = dataObject.Image; if (!string.IsNullOrEmpty(dataObject.EagerHistory)) upInfo.EagerHistory = dataObject.EagerHistory; if (!string.IsNullOrEmpty(dataObject.GradeHistory)) upInfo.GradeHistory = dataObject.GradeHistory; if (dataObject.EagerAmount != 0) upInfo.EagerAmount = dataObject.EagerAmount; if (dataObject.GradeAverage != 0) upInfo.GradeAverage = dataObject.GradeAverage; if (dataObject.ActEnum != 0) upInfo.ActEnum = dataObject.ActEnum; productRepository.Update(upInfo); } }
public void ProductUpdate(ProductData dataObject) { try { productService.ProductUpdate(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 ProductData ProductSubmit(ProductData subInfo, Boolean force) { try { return productService.ProductSubmit(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 ProductData ProductSubmit(ProductData dataObject, bool force) { if (dataObject == null) throw new ArgumentNullException("productDataObject"); using (IRepositoryContext context = IocLocator.Instance.GetImple<IRepositoryContext>()) { var productRepository = context.GetRepository<Product>(); Product product = Mapper.Map<ProductData, Product>(dataObject); product.ActEnum = force ? (int)eAct.Normal : (int)eAct.unApproved; productRepository.Add(product); context.Commit(); return Mapper.Map<Product, ProductData>(product); } }