コード例 #1
0
 public override void ValidateUpdate(Cast targetObject, IEnumerable <Cast> items)
 {
     base.ValidateUpdate(targetObject);
     if (items.Any(e => e.Id != targetObject.Id & (e.VideoId == targetObject.VideoId & e.FullName.CompareTo(targetObject.FullName) == 0)))
     {
         ValidationExceptionService.Add("", "Unable to update Cast.");
     }
     ValidationExceptionService.ThrowException();
 }
コード例 #2
0
 public override void ValidateInsert(Role targetObject, IEnumerable <Role> items)
 {
     base.ValidateInsert(targetObject);
     if (items != null & items.Any(e => string.Compare(e.Name, targetObject.Name, true) == 0))
     {
         ValidationExceptionService.Add(Guid.NewGuid().ToString(), "Cannot insert a duplicate Role.");
     }
     ValidationExceptionService.ThrowException();
 }
コード例 #3
0
        public override void ValidateUpdate(Video targetObject, IEnumerable <Video> items)
        {
            base.ValidateUpdate(targetObject);

            if (items != null && items.Any(elem => elem.Id != targetObject.Id && string.Compare(elem.Title, targetObject.Title) == 0))
            {
                ValidationExceptionService.Add(Guid.NewGuid().ToString(), "Unable to update Video, there's already a Video with the same name.");
            }
            ValidationExceptionService.ThrowException();
        }
コード例 #4
0
        public override void ValidateInsert(Genre targetObject, IEnumerable <Genre> items)
        {
            base.ValidateInsert(targetObject);

            if (items != null && items.Any(elem => string.Compare(elem.Name, targetObject.Name) == 0))
            {
                ValidationExceptionService.Add(Guid.NewGuid().ToString(), "Unable to insert Genre, there's already a Genre with the same name.");
            }
            ValidationExceptionService.ThrowException();
        }
コード例 #5
0
        public override void ValidateUpdate(DislikeLike targetObject, IEnumerable <DislikeLike> items)
        {
            base.ValidateUpdate(targetObject);

            if (items != null && items.Any(elem => elem.Id != targetObject.Id && string.Compare(elem.IsLike.ToString(), targetObject.IsLike.ToString()) == 0))
            {
                ValidationExceptionService.Add(Guid.NewGuid().ToString(), "Unable to update Genre, there's already a Genre with the same name.");
            }
            ValidationExceptionService.ThrowException();
        }
コード例 #6
0
        public override void ValidateInsert(UserRoles targetObject, IEnumerable <UserRoles> items)
        {
            base.ValidateInsert(targetObject);
            var workingSet = items.Where(e => !e.IsDeleted);

            if (workingSet.Any(e => e.RoleID == targetObject.RoleID & e.UserID == targetObject.UserID))
            {
                ValidationExceptionService.Add(Guid.NewGuid().ToString(), "Cannot insert a duplicate Role for the User.");
            }
            ValidationExceptionService.ThrowException();
        }