private void ParseAlbumLabelAndVendor(IExplodedReview <Album> explodedReview) { var review = explodedReview as AlbumExplodedReview; if (review == null) { throw new InvalidCastException("explodedReview cannot be cast as AlbumExplodedReview"); } LabelVendor labelVendor = null; if (_albumLabelsParser.TryParse(review.AlbumLabel, review.AlbumDistributor, review.RecordLastUpdateDate, review.RecordId, ref labelVendor)) { review.ProcessedLabelVendor = labelVendor; } }
public static LabelVendor CreateOrUpdate(string label, string vendor, DateTime lastUpdate) { if (string.IsNullOrEmpty(label)) { throw new ArgumentNullException("label"); } var lb = label.Trim(); var vd = vendor.Trim(); var existingLb = LabelVendors.Where(x => x.Label.ToUpperInvariant() == lb.ToUpperInvariant()).SingleOrDefault(); if (existingLb == null) { var labelVendor = new LabelVendor(AlbumLabelsIdGenerator.NewID(), lb, vd, lastUpdate); LabelVendors.Add(labelVendor); return(labelVendor); } existingLb.UpdateVendor(vd, lastUpdate); return(existingLb); }
public bool TryParse(string label, string vendor, DateTime reviewDate, int reviewId, ref LabelVendor labelVendor) { try { if (string.IsNullOrEmpty(label)) { throw new ArgumentNullException("label"); } labelVendor = AlbumLabelsRepository.CreateOrUpdate(label, vendor ?? string.Empty, reviewDate); return(true); } catch (Exception e) { var message = string.Format("cannot parse label and vendor '{0}/{1}'\n : {2}", label, vendor, e.Message); Logging.Logging.Instance.LogError(string.Format("Une erreur est survenue lors de l'extraction du style de la review {0} : {1}", reviewId, message), ErrorLevel.Info); return(false); } }