Пример #1
0
        /// <summary>
        /// 创建圈人
        /// </summary>
        /// <param name="label">圈人对象</param>
        /// <returns>返回创建是否成功</returns>
        public bool CreateLabel(PhotoLabel label)
        {
            photoLabelRepository.Insert(label);
            EventBus <PhotoLabel> .Instance().OnAfter(label, new CommonEventArgs(EventOperationType.Instance().Create()));

            return(label.LabelId > 0);
        }
Пример #2
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        public static PhotoLabel New()
        {
            PhotoLabel label = new PhotoLabel()
            {
                DateCreated  = DateTime.UtcNow,
                LastModified = DateTime.UtcNow
            };

            return(label);
        }
Пример #3
0
 //转换为可以编辑的实体
 public static PhotoLabelEditModel AsPhotoEditModel(this PhotoLabel label)
 {
     return(new PhotoLabelEditModel
     {
         AreaHeight = label.AreaHeight,
         AreaWidth = label.AreaWidth,
         AreaX = label.AreaX,
         AreaY = label.AreaY,
         DateCreated = label.DateCreated,
         Description = label.Description,
         LabelId = label.LabelId,
         LastModified = label.LastModified,
         ObjectName = label.ObjectName,
         ObjetId = label.ObjetId,
         PhotoId = label.PhotoId,
         TenantTypeId = label.TenantTypeId,
         UserId = label.UserId,
         CanEdit = DIContainer.Resolve <Authorizer>().PhotoLabel_Delete(label),
         UserLink = SiteUrls.Instance().SpaceHome(label.ObjetId)
     });
 }
Пример #4
0
        /// <summary>
        /// 删除圈人
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="label">圈人信息</param>
        /// <returns></returns>
        public static bool PhotoLabel_Delete(this Authorizer authorizer, PhotoLabel label)
        {
            if (label == null)
            {
                return(false);
            }

            if (UserContext.CurrentUser == null)
            {
                return(false);
            }

            if (label.UserId == UserContext.CurrentUser.UserId)
            {
                return(true);
            }

            if (label.Photo.UserId == UserContext.CurrentUser.UserId)
            {
                return(true);
            }

            return(authorizer.IsAdministrator(PhotoConfig.Instance().ApplicationId));
        }
Пример #5
0
 /// <summary>
 /// 删除圈人
 /// </summary>
 /// <param name="label">圈人对象</param>
 public void DeleteLabel(PhotoLabel label)
 {
     photoLabelRepository.Delete(label);
     EventBus <PhotoLabel> .Instance().OnAfter(label, new CommonEventArgs(EventOperationType.Instance().Delete()));
 }
Пример #6
0
 /// <summary>
 /// 编辑圈人
 /// </summary>
 /// <param name="label">圈人对象</param>
 public void UpdateLabel(PhotoLabel label)
 {
     photoLabelRepository.Update(label);
 }