public async Task <IResponseModel> AddPropertyAsync(IPropertyModel model)
        {
            try
            {
                var property = new RealEstateProperty
                {
                    Id         = Guid.NewGuid(),
                    UserId     = model.UserId,
                    Name       = model.Name,
                    Address    = model.Address,
                    City       = model.City,
                    ContactNo  = model.ContactNo,
                    Owner      = model.Owner,
                    TotalRooms = model.TotalRooms
                };

                _db.RealEstateProperties.Add(property);
                await _db.SaveChangesAsync();

                _response.Status  = true;
                _response.Message = "Property added successfully.";

                return(_response);
            }
            catch (Exception ex)
            {
                _loggerService.Log("Add New Property", ex.InnerException.Message, ex.Message, ex.StackTrace);

                _response.Status  = false;
                _response.Message = "Error adding property.";

                return(_response);
            }
        }
Exemplo n.º 2
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is FloatProperty floatProperty)
     {
         FloatValue.Value = floatProperty.FloatValue.Value;
     }
 }
Exemplo n.º 3
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is StringProperty stringProperty)
     {
         StringValue.Value = stringProperty.StringValue.Value;
     }
 }
Exemplo n.º 4
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is MiscProperty miscProperty)
     {
         Value.Value = miscProperty.Value.Value;
     }
 }
Exemplo n.º 5
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is ClassProperty classProperty)
     {
         structureValue_.CopyFrom(classProperty.structureValue_);
     }
 }
Exemplo n.º 6
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is StructProperty structProperty)
     {
         StructureValue.CopyFrom(structProperty.StructureValue);
     }
 }
Exemplo n.º 7
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is EnumProperty enumProperty)
     {
         EnumValue.Value = enumProperty.EnumValue.Value;
     }
 }
Exemplo n.º 8
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is BoolProperty boolProperty)
     {
         boolProperty.BoolValue.Value = BoolValue.Value;
     }
 }
 public PropertyCompounder(IPropertyModel model, ViewModelFactory factory)
 {
     UsePlugin  = true;
     this.model = model;
     router     = new ViewModelRouter(factory);
     CompoundOnChangedObservable = Observable.Empty <Unit>();
 }
Exemplo n.º 10
0
    public static void Load(this IPropertyModel @this, ICodeTextWriter writer, SourceBuilder builder, IPropertySymbol property, ScopeInfo scope, IEnumerable <IMemberInfo> references)
    {
        {
            SourceBuilder builder2 = builder.AppendNewBuilder(false);
            writer.WriteIdentifier(builder2, property);
            @this.Name = builder2.ToString();
        }

        {
            SourceBuilder builder2 = builder.AppendNewBuilder(false);
            writer.WriteTypeReference(builder2, property.Type, scope);
            @this.Type = builder2.ToString();
        }

        @this.HaveGetter = property.GetMethod != null;
        @this.HaveSetter = property.SetMethod != null;

        foreach (IMemberInfo reference in references)
        {
            SourceBuilder builder2 = builder.AppendNewBuilder(false);
            writer.WritePropertyCall(builder2, reference, property, scope, SemanticFacts.IsNullable(writer.Compilation, property.Type), false);
            @this.Expressions.Add(builder2.ToString());
        }

        if (@this is ILocalPropertyExpressionModel this2)
        {
            this2.Load(writer, builder, property, scope, references);
        }
    }
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is ReferenceByIntProperty referenceProperty)
     {
         SelectedObject.Value = referenceProperty.SelectedObject.Value;
     }
 }
Exemplo n.º 12
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is IntProperty intProp)
     {
         IntValue.Value = intProp.IntValue.Value;
     }
 }
 public void Initialize()
 {
     var doc = new ProjectModel();
     doc.LoadXml(NUnitProjectXml.EmptyConfigs);
     model = new PropertyModel(doc);
     dlg = Substitute.For<IRenameConfigurationDialog>();
     presenter = new RenameConfigurationPresenter(model, dlg, "Debug");
 }
Exemplo n.º 14
0
        public PropertyPresenter(IPropertyModel model, IPropertyView view)
        {
            _model = model;
            _view  = view;

            InitializeView();
            WireUpEvents();
        }
Exemplo n.º 15
0
        public PropertyPage()
        {
            this.InitializeComponent();

            ViewModel = FreshIOC.Container.Resolve <IPropertyModel>();

            this.DataContext = ViewModel.Properties;
        }
        public PropertyPresenter(IPropertyModel model, IPropertyView view)
        {
            _model = model;
            _view = view;

            InitializeView();
            WireUpEvents();
        }
Exemplo n.º 17
0
        public void Initialize()
        {
            var doc = new ProjectModel();

            doc.LoadXml(NUnitProjectXml.EmptyConfigs);
            model     = new PropertyModel(doc);
            dlg       = Substitute.For <IRenameConfigurationDialog>();
            presenter = new RenameConfigurationPresenter(model, dlg, "Debug");
        }
Exemplo n.º 18
0
        public ReactiveProperty <string> GetStringProperty(IPropertyModel model, string route)
        {
            var m = GetValuePropertyModel(model, route);

            if (m is StringProperty p)
            {
                return(p.StringValue);
            }
            throw new InvalidCastException($"{route} は string 型ではありません。");
        }
Exemplo n.º 19
0
        public ReactiveProperty <float> GetFloatProperty(IPropertyModel model, string route)
        {
            var m = GetValuePropertyModel(model, route);

            if (m is FloatProperty p)
            {
                return(p.FloatValue);
            }
            throw new InvalidCastException($"{route} は float 型ではありません。");
        }
        public void SetUp()
        {
            var doc = new ProjectModel();
            doc.LoadXml(NUnitProjectXml.NormalProject);
            model = new PropertyModel(doc);

            dlg = Substitute.For<IAddConfigurationDialog>();

            presenter = new AddConfigurationPresenter(model, dlg);
        }
Exemplo n.º 21
0
        public ReactiveProperty <bool> GetBoolProperty(IPropertyModel model, string route)
        {
            var m = GetValuePropertyModel(model, route);

            if (m is BoolProperty p)
            {
                return(p.BoolValue);
            }
            throw new InvalidCastException($"{route} は bool 型ではありません。");
        }
        public void SetUp()
        {
            var doc = new ProjectModel();

            doc.LoadXml(NUnitProjectXml.NormalProject);
            model = new PropertyModel(doc);

            dlg = Substitute.For <IAddConfigurationDialog>();

            presenter = new AddConfigurationPresenter(model, dlg);
        }
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is ReferenceByIntCollectionProperty collectionProperty)
     {
         foreach (var item in collectionProperty.CollectionValue.Collection)
         {
             var clone = AddNewElement();
             clone.CopyFrom(item.model);
         }
     }
 }
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is BasicCollectionProperty collectionProperty &&
         CollectionValue.ItemType == collectionProperty.CollectionValue.ItemType)
     {
         foreach (var item in collectionProperty.CollectionValue.Collection)
         {
             var clone = AddNewElement();
             clone.CopyFrom(item.model);
         }
     }
 }
Exemplo n.º 25
0
 public override void CopyFrom(IPropertyModel property)
 {
     if (property is SubtypingProperty subtypingProperty)
     {
         // 具象型が未設定の時はコピー先も未設定にする
         if (subtypingProperty.SelectedType.Value != null)
         {
             SelectedType.Value = AvailableTypes.FirstOrDefault(x => x.Type == subtypingProperty.SelectedType.Value.Type);
             Model.Value.CopyFrom(subtypingProperty.Model.Value);
         }
     }
 }
        public ConfigurationEditor(IPropertyModel model, IConfigurationEditorDialog view)
        {
            this.model = model;
            this.view = view;

            UpdateConfigList();

            view.AddCommand.Execute += AddConfig;
            view.RemoveCommand.Execute += RemoveConfig;
            view.RenameCommand.Execute += RenameConfig;
            view.ActiveCommand.Execute += MakeActive;

            view.ConfigList.SelectionChanged += SelectedConfigChanged;
        }
Exemplo n.º 27
0
        public AddConfigurationPresenter(IPropertyModel model, IAddConfigurationDialog dlg)
        {
            this.model = model;
            this.dlg   = dlg;

            dlg.ConfigList = model.ConfigNames;

            dlg.OkButton.Execute += delegate
            {
                if (dlg.ConfigToCreate == string.Empty)
                {
                    dlg.MessageDisplay.Error("No configuration name provided");
                    return;
                }

                foreach (string config in model.ConfigNames)
                {
                    if (config == dlg.ConfigToCreate)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                IProjectConfig newConfig = model.AddConfig(dlg.ConfigToCreate);

                if (dlg.ConfigToCopy != null)
                {
                    IProjectConfig copyConfig = model.Configs[dlg.ConfigToCopy];
                    if (copyConfig != null)
                    {
                        newConfig.BasePath    = copyConfig.BasePath;
                        newConfig.BinPathType = copyConfig.BinPathType;
                        if (newConfig.BinPathType == BinPathType.Manual)
                        {
                            newConfig.PrivateBinPath = copyConfig.PrivateBinPath;
                        }
                        newConfig.ConfigurationFile = copyConfig.ConfigurationFile;
                        newConfig.RuntimeFramework  = copyConfig.RuntimeFramework;

                        foreach (string assembly in copyConfig.Assemblies)
                        {
                            newConfig.Assemblies.Add(assembly);
                        }
                    }
                }

                dlg.Close();
            };
        }
        public ConfigurationEditor(IPropertyModel model, IConfigurationEditorDialog view)
        {
            this.model = model;
            this.view  = view;

            UpdateConfigList();

            view.AddCommand.Execute    += AddConfig;
            view.RemoveCommand.Execute += RemoveConfig;
            view.RenameCommand.Execute += RenameConfig;
            view.ActiveCommand.Execute += MakeActive;

            view.ConfigList.SelectionChanged += SelectedConfigChanged;
        }
Exemplo n.º 29
0
        public ReactiveProperty <int> GetIntProperty(IPropertyModel model, string route)
        {
            var m = GetValuePropertyModel(model, route);

            if (m is IntProperty p)
            {
                return(p.IntValue);
            }
            else if (m is ReferenceByIntProperty q)
            {
                return(q.IntValue);
            }
            throw new InvalidCastException($"{route} は int 型ではありません。");
        }
Exemplo n.º 30
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates a new item that can be added into to the collection.
        /// </summary>
        /// <param name="propertyModel">The <see cref="IPropertyModel"/> associated with the collection.</param>
        /// <returns>The item that was created.</returns>
        public override object CreateItem(IPropertyModel propertyModel)
        {
            var parent = propertyModel.Target as Person;

            var names = new string[] { "Noah", "Liam", "Mason", "Ethan", "Michael", "Jacob", "Alexander", "Emma", "Olivia", "Sophia", "Isabella", "Ava", "Mia", "Emily", "Abigail" };
            var rand  = new Random();

            var child = new Person();

            child.Birthday  = DateTime.Today;
            child.LastName  = parent.LastName;
            child.FirstName = names[rand.Next(names.Length)];

            return(child);
        }
Exemplo n.º 31
0
        public ToleranceViewModel(IPropertyModel model, PropertyFactory propertyFactory, ViewModelFactory factory)
            : base(model, factory)
        {
            var catalog   = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            var container = new CompositionContainer(catalog);

            UserControl             = container.GetExportedValue <UserControl>("ToleranceView");
            UserControl.DataContext = this;

            Blow     = Compounder.CreateIntViewModel("Blow");
            Gash     = Compounder.CreateIntViewModel("Gash");
            Burn     = Compounder.CreateIntViewModel("Burn");
            Chill    = Compounder.CreateIntViewModel("Chill");
            Electric = Compounder.CreateIntViewModel("Electric");
            Primal   = Compounder.CreateIntViewModel("Primal");
        }
        public void AddNewElementTest()
        {
            var property = new BasicCollectionProperty(typeof(int[]), new PropertyFactory());

            property.AddNewElement();

            var expected = new IPropertyModel[]
            {
                new IntProperty()
                {
                    Title = { Value = CollectionHolder.ElementTitle }
                }
            };

            property.Collection.ToArray()
            .IsStructuralEqual(expected);
        }
        public AddConfigurationPresenter(IPropertyModel model, IAddConfigurationDialog dlg)
        {
            this.model = model;
            this.dlg = dlg;

            dlg.ConfigList = model.ConfigNames;

            dlg.OkButton.Execute += delegate
            {
                if (dlg.ConfigToCreate == string.Empty)
                {
                    dlg.MessageDisplay.Error("No configuration name provided");
                    return;
                }

                foreach (string config in model.ConfigNames)
                {
                    if (config == dlg.ConfigToCreate)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                IProjectConfig newConfig = model.AddConfig(dlg.ConfigToCreate);

                if (dlg.ConfigToCopy != null)
                {
                    IProjectConfig copyConfig = model.Configs[dlg.ConfigToCopy];
                    if (copyConfig != null)
                    {
                        newConfig.BasePath = copyConfig.BasePath;
                        newConfig.BinPathType = copyConfig.BinPathType;
                        if (newConfig.BinPathType == BinPathType.Manual)
                            newConfig.PrivateBinPath = copyConfig.PrivateBinPath;
                        newConfig.ConfigurationFile = copyConfig.ConfigurationFile;
                        newConfig.RuntimeFramework = copyConfig.RuntimeFramework;

                        foreach (string assembly in copyConfig.Assemblies)
                            newConfig.Assemblies.Add(assembly);
                    }
                }

                dlg.Close();
            };
        }
Exemplo n.º 34
0
        public void SetUp()
        {
            doc = new ProjectModel();
            doc.LoadXml(NUnitProjectXml.NormalProject);
            model = new PropertyModel(doc);
            model.ActiveConfigName = "Release";

            view = Substitute.For <IPropertyView>();
            view.ConfigList.Returns(new SelectionStub("ConfigList"));
            view.ProcessModel.Returns(new SelectionStub("ProcessModel"));
            view.DomainUsage.Returns(new SelectionStub("DomainUsage"));
            view.Runtime.Returns(new SelectionStub("Runtime"));
            view.RuntimeVersion.Returns(new SelectionStub("RuntimeVersion"));
            view.AssemblyList.Returns(new SelectionStub("AssemblyList"));

            new PropertyPresenter(model, view);
            view.Selected += Raise.Event <ActionHandler>();
        }
Exemplo n.º 35
0
        public IPropertyViewModel Create(IPropertyModel model, bool usePlugin = true)
        {
            if (usePlugin)
            {
                var factory = Factories.FirstOrDefault(x => x.IsTargetType(model.ValueType));
                if (factory != null)
                {
                    return(factory.CreateViewModel(model, modelFactory_, this));
                }
            }

            switch (model)
            {
            case IntProperty p: return(new IntViewModel(p));

            case BoolProperty p: return(new BoolViewModel(p));

            case FloatProperty p: return(new FloatViewModel(p));

            case StringProperty p when !p.IsMultiLine: return(new StringViewModel(p));

            case StringProperty p when p.IsMultiLine: return(new MultilineStringViewModel(p));

            case EnumProperty p: return(new EnumViewModel(p));

            case ClassProperty p: return(new ClassViewModel(p, this));

            case StructProperty p: return(new StructViewModel(p, this));

            case SubtypingProperty p: return(new SubtypingViewModel(p, this));

            case BasicCollectionProperty p: return(new BasicCollectionViewModel(p, this));

            case ComplicateCollectionProperty p: return(new ComplicateCollectionViewModel(p, this));

            case ReferenceByIntCollectionProperty p: return(new ReferenceByIntCollectionViewModel(p, this));

            case ReferenceByIntProperty p: return(new ReferenceByIntViewModel(p));

            default: throw new ArgumentException("開発者向け:ViewModelの生成に失敗しました。");
            }
        }
        public RenameConfigurationPresenter(IPropertyModel model, IRenameConfigurationDialog dlg, string originalName)
        {
            this.model = model;
            this.dlg = dlg;
            this.originalName = originalName;

            dlg.ConfigurationName.Text = originalName;
            dlg.ConfigurationName.Select(0, originalName.Length);

            dlg.ConfigurationName.Changed += delegate
            {
                string text = dlg.ConfigurationName.Text;
                dlg.OkButton.Enabled = text != string.Empty && text != originalName;
            };

            dlg.OkButton.Execute += delegate
            {
                string newName = dlg.ConfigurationName.Text;

                foreach (string existingName in model.ConfigNames)
                {
                    if (existingName == newName)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                model.Configs[originalName].Name = newName;

                if (model.ActiveConfigName == originalName)
                    model.ActiveConfigName = newName;

                dlg.Close();
            };
        }
Exemplo n.º 37
0
        private IEnumerable<string> GetProperty(IPropertyModel p)
        {
            foreach (var attribute in p.Attributes)
            {
                yield return $"[{attribute.GetType().FullName}]";
            }

            var visibility = GetVisibility(p.Visibility);
            var s = $"{visibility} {p.TypeFullName} {p.Name}";
            if (p.HasGetter || p.HasSetter)
            {
                s += " {";
                if (p.HasGetter)
                {
                    s += " get;";
                }
                if (p.HasSetter)
                {
                    s += " set;";
                }
                s += " }";
            }
            yield return s;
        }
        public void SetUp()
        {
            doc = new ProjectModel();
            doc.LoadXml(NUnitProjectXml.NormalProject);
            model = new PropertyModel(doc);
            model.ActiveConfigName = "Release";

            view = Substitute.For<IPropertyView>();
            view.ConfigList.Returns(new SelectionStub("ConfigList"));
            view.ProcessModel.Returns(new SelectionStub("ProcessModel"));
            view.DomainUsage.Returns(new SelectionStub("DomainUsage"));
            view.Runtime.Returns(new SelectionStub("Runtime"));
            view.RuntimeVersion.Returns(new SelectionStub("RuntimeVersion"));
            view.AssemblyList.Returns(new SelectionStub("AssemblyList"));

            new PropertyPresenter(model, view);
            view.Selected += Raise.Event<ActionHandler>();
        }