/// <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); }
/// <summary> /// 新建实体时使用 /// </summary> public static PhotoLabel New() { PhotoLabel label = new PhotoLabel() { DateCreated = DateTime.UtcNow, LastModified = DateTime.UtcNow }; return(label); }
//转换为可以编辑的实体 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) }); }
/// <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)); }
/// <summary> /// 删除圈人 /// </summary> /// <param name="label">圈人对象</param> public void DeleteLabel(PhotoLabel label) { photoLabelRepository.Delete(label); EventBus <PhotoLabel> .Instance().OnAfter(label, new CommonEventArgs(EventOperationType.Instance().Delete())); }
/// <summary> /// 编辑圈人 /// </summary> /// <param name="label">圈人对象</param> public void UpdateLabel(PhotoLabel label) { photoLabelRepository.Update(label); }