Пример #1
0
 def build(self) -> Function:
     function = Function(Id=self._id, Name=self._name)
     function.save()
     for property in self._properties:
         property.save()
         function.Properties.add(property)
     return function
Пример #2
0
    def Save(self, data):
        if type(data) is Function:
            model = data
        else:
            model = Function()
            model.Id = data.get("Id", "")
            model.Name = data.get("Name", "")

        function = self.Get(model.Id)
        status = self.Status(model, function)
        if status is ModelStatus.New:
            model.Id = None
            model.save()
        elif status is ModelStatus.Modified:
            model.save()

        if type(data) is not Function:
            Properties = data['Properties']
            for propertyDict in Properties:
                property = self.__propertyRepo.Save(propertyDict)
                model.Properties.add(property.Id)

        return model