internal static ResourceArticleUserRatingEntity Map(this ResourceRating rating) { var entity = new ResourceArticleUserRatingEntity { id = rating.Id, resourceArticleId = rating.ResourceId, userId = rating.UserId, resourceType = (byte)rating.ResourceType, }; rating.MapTo(entity); return(entity); }
void IResourcesRepository.UpdateResourceRating(ResourceRating rating) { using (var dc = CreateContext()) { var entity = GetResourceArticleUserRatingEntity(dc, rating.ResourceId, rating.UserId); if (entity == null) { dc.ResourceArticleUserRatingEntities.InsertOnSubmit(rating.Map()); } else { rating.MapTo(entity); } dc.SubmitChanges(); } }