예제 #1
0
        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);
        }
예제 #2
0
        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();
            }
        }