Exemplo n.º 1
0
        internal BusinessObjectActionReport <RatingDataRepositoryActionStatus> Create(CMSContentRating cmsContentRating, bool getBaseRatingInfo, bool allowSelfRating, out BaseRatingInfo baseRatingInfo)
        {
            baseRatingInfo = null;
            BusinessObjectActionReport <RatingDataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <RatingDataRepositoryActionStatus>(RatingDataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContentRating);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_ContentRatings_InsertOrUpdate(cmsContentRating.Rating, cmsContentRating.CMSContentId, cmsContentRating.CMSUserId, allowSelfRating);
                        if (getBaseRatingInfo)
                        {
                            baseRatingInfo = dataStoreContext.cms_Contents_GetBaseRatingInfo(cmsContentRating.CMSContentId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_ContentRatings_InsertOrUpdate, cms_Contents_GetBaseRatingInfo", ex);
                    throw new DataStoreException(ex, true);
                }
                switch (num)
                {
                case -1:
                    businessObjectActionReport.Status = RatingDataRepositoryActionStatus.SelfRatingNotAllowed;
                    break;

                case 0:
                    cmsContentRating.DateCreatedUtc = DateTime.UtcNow;
                    break;

                default:
                    businessObjectActionReport.Status = RatingDataRepositoryActionStatus.SqlError;
                    _Log.ErrorFormat("CMSContentRating {0} was not inserted at the database (ErrorCode: {1})."
                                     , DebugUtility.GetObjectString(cmsContentRating), num);
                    break;
                }
            }
            else
            {
                businessObjectActionReport.Status = RatingDataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContentRating {0} was not inserted at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContentRating)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }
Exemplo n.º 2
0
 public BusinessObjectActionReport <RatingDataRepositoryActionStatus> CreateOrUpdateExisting(MessageRating messageRating, out BaseRatingInfo baseRatingInfo)
 {
     return(_CMSContentRatingManager.Create(messageRating.CMSContentRating, true, false, out baseRatingInfo));
 }
Exemplo n.º 3
0
        internal BusinessObjectActionReport <RatingDataRepositoryActionStatus> Create(CMSContentRating cmsContentRating)
        {
            BaseRatingInfo baseRatingInfo = null;

            return(this.Create(cmsContentRating, false, false, out baseRatingInfo));
        }
Exemplo n.º 4
0
 public BusinessObjectActionReport <RatingDataRepositoryActionStatus> Create(MessageRating messageRating, out BaseRatingInfo baseRatingInfo)
 {
     return(this.CreateOrUpdateExisting(messageRating, out baseRatingInfo));
 }