public void InsertOrUpdate(GoodDTO good) { if (good.ImgLink == null) { good.ImgLink = @"http://www.kalahandi.info/wp-content/uploads/2016/05/sorry-image-not-available.png"; } var goodDb = Mapper.Map <Good>(good); goodDb.Status = true; var request = sqlUnitOfWork.GoodRepo.All.FirstOrDefault(x => x.UrlLink == goodDb.UrlLink); if (request != null) { good.Id = request.Id; Update(good); } else { var res = sqlUnitOfWork.GoodRepo.Insert(goodDb); try { if (sqlUnitOfWork.Save() < 1) { throw new Exception("Item isn't added into MS SQL Server"); } var elasticGood = Mapper.Map <GoodDTO>(res); //elastic manipulation elasticUnitOfWork.Repository.Insert(elasticGood); elasticUnitOfWork.Save(); } catch (Exception ex) { Logger.Error(ex.Message); } } }
public void Insert(GoodDTO good) { elasticUOW.Repository.Insert(good); elasticUOW.Save(); }