Beispiel #1
0
        protected void RelateInternal(IClassifiable relatable, IClassifiable related, RelationDirection direction, TaxonomyNode type)
        {
            var currentRelation = GetRelation(relatable, related, type);

            if (direction == RelationDirection.Undefined)
            {
                if (currentRelation != null)
                {
                    relationRepo.Delete(currentRelation);
                }
                //do nothing if direction is undefined
            }
            else
            {
                if (currentRelation == null)
                {
                    currentRelation = RelationEntity.Create(relatable, related, type == null?null:type.entity, direction);
                    relationRepo.Save(currentRelation);
                }
                else
                {
                    currentRelation.Direction = direction;
                    relationRepo.Update(currentRelation);
                }
            }
        }
Beispiel #2
0
        public JsonResult AddRelationForVehicle(long vehicleId, long relationId)
        {
            try
            {
                var relation = blRelation.Find(relationId);
                relation.VehicleId = vehicleId;
                string message = "";
                if (blRelation.Update(relation, out message))
                {
                    return(Json(new JsonData()
                    {
                        Success = true,
                        Script = MessageBox.Show("عملیات درج با موفقیت انجام شد", MessageType.Success).Script,
                        Html = ""
                    }));
                }
                else
                {
                    var    vehicle  = blVehicle.Find(vehicleId);
                    string message2 = "";
                    blVehicle.Delete(vehicle, out message2);

                    return(Json(new JsonData()
                    {
                        Success = false,
                        Script = MessageBox.Show("خطا رخ داده است. مجددا تلاش کنید", MessageType.Error).Script,
                        Html = ""
                    }));
                }
            }
            catch
            {
                return(Json(new JsonData()
                {
                    Success = false,
                    Script = MessageBox.Show("خطا رخ داده است. مجددا تلاش کنید", MessageType.Error).Script,
                    Html = ""
                }));
            }
        }
Beispiel #3
0
        public MyHourMutation(UserRepository userRepository, RelationRepository relationRepository, ProjectRepository projectRepository)
        {
            Field <RelationType>("createRelation",
                                 arguments: new QueryArguments(new QueryArgument <NonNullGraphType <RelationInputType> > {
                Name = "input"
            }),
                                 resolve: context => relationRepository.Create(context.GetArgument <Relation>("input"))
                                 );

            Field <RelationType>("deleteRelation",
                                 arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            }),
                                 resolve: context => relationRepository.Delete(context.GetArgument <long>("id"))
                                 );

            Field <RelationType>("updateRelation",
                                 arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            },
                                                               new QueryArgument <NonNullGraphType <RelationInputType> > {
                Name = "input"
            }),
                                 resolve: context => relationRepository.Update(context.GetArgument <long>("id"),
                                                                               context.GetArgument <Relation>("input"))
                                 );
            Field <RelationType>("updateRelationTime",
                                 arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            },
                                                               new QueryArgument <NonNullGraphType <RelationInputType> > {
                Name = "input"
            }),
                                 resolve: context => relationRepository.UpdateTime(context.GetArgument <long>("id"),
                                                                                   context.GetArgument <Relation>("input"))
                                 );

            Field <ProjectType>("createProject",
                                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ProjectInputType> > {
                Name = "input"
            }),
                                resolve: context => projectRepository.Create(context.GetArgument <Project>("input"))
                                );

            Field <ProjectType>("deleteProject",
                                arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            }),
                                resolve: context => projectRepository.Delete(context.GetArgument <long>("id"))
                                );

            Field <ProjectType>("updateProject",
                                arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            },
                                                              new QueryArgument <NonNullGraphType <ProjectInputType> > {
                Name = "input"
            }),
                                resolve: context => projectRepository.Update(context.GetArgument <long>("id"),
                                                                             context.GetArgument <Project>("input"))
                                );

            Field <UserType>("createUser",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <UserInputType> > {
                Name = "input"
            }),
                             resolve: context => userRepository.Create(context.GetArgument <User>("input"))
                             );

            Field <UserType>("deleteUser",
                             arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            }),
                             resolve: context => userRepository.Delete(context.GetArgument <long>("id"))
                             );

            Field <UserType>("updateUser",
                             arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            },
                                                           new QueryArgument <NonNullGraphType <UserInputType> > {
                Name = "input"
            }),
                             resolve: context => userRepository.Update(context.GetArgument <long>("id"),
                                                                       context.GetArgument <User>("input"))
                             );
        }