Esempio n. 1
0
        public async Task <ActionResult> AddField(ViewFieldModel model)
        {
            //Defines the properties model key
            _KeyId.SetKey(); //Sets a new properties ObjectID collection;
            string propertiesId = _KeyId.GetKey();

            //First must create properties model;
            PropertiesModel properties = new PropertiesModel()
            {
                ID        = propertiesId,
                Size      = Convert.ToInt32(model.Size),
                Value     = model.Value,
                Maxlength = Convert.ToInt32(model.Maxlength),
                Required  = Convert.ToBoolean(model.Required)
            };

            _KeyId.SetKey(); //Sets a new properties ObjectID collection;
            string fieldId = _KeyId.GetKey();

            //Third creates field model
            FieldModel field = new FieldModel()
            {
                Id         = fieldId,
                Name       = model.Name,
                Type       = model.Type,
                Properties = propertiesId,
                Date       = DateTime.Now.ToLocalTime()
            };

            _Connection.DatabaseConnection();
            _Properties.SetDatabase(_Connection.GetDatabase());
            _Properties.CreateProperties(properties);

            _Field.SetDatabase(_Connection.GetDatabase());
            _Field.CreateField(field);

            _Metadata.SetProcessVersion(model.ProcessID);
            _Metadata.AddFieldToProcess(model.ProcessID, fieldId);

            return(await Task.Run(() => RedirectToAction("Read", "Field", new { ProcessId = model.ProcessID })));
        }