private void GetRetailerID(string retailerName) { using (DbModelContext dbContext = new DbModelContext()) { RetailerID = dbContext.Vanzator.Where(m => m.Nume.Equals(retailerName, StringComparison.InvariantCultureIgnoreCase)).Select(m => m.Id).FirstOrDefault(); } }
private void GetRetailer(Guid retailerID) { using (DbModelContext dbContext = new DbModelContext()) { if (retailerID != new Guid()) { retailer = dbContext.Vanzator.Where(ret => ret.Id.Equals(RetailerID)).FirstOrDefault(); } } }
public void SaveProducts(string givenMessage) { using (DbModelContext dbContext = new DbModelContext()) { string searchCode = GetSearchCode(givenMessage); foreach (var item in this) { try { if (dbContext.Produs.Any(prd => prd.Id.Equals(item.Id))) { dbContext.EvolutiaPretului.Add(item.EvolutiaPretului.OrderByDescending(m => m.Data_Actualizare).First()); } else { dbContext.Produs.Add(item); } dbContext.AparitieProdus.Add(new AparitieProdus { Id_Cautare = StringToGuid(givenMessage) , Id_Produs = item.Id, Id = StringToGuid($"{StringToGuid(givenMessage).ToString()}{item.Id.ToString()})") }); dbContext.SaveChanges(); } catch (Exception ex) { GenericLogger.Error($"Batch failed to insert {ex.Message} \n {ex.InnerException.InnerException.Message}"); } } } }