Exemplo n.º 1
0
        public void Constructor_AmountProvided_ProvidedAmountSet()
        {
            var amount       = 10;
            var addAttribute = new AddAttribute(amount);

            Assert.AreEqual(amount, addAttribute.Amount);
        }
        private void BtnAddAttribute_Click(object sender, EventArgs e)
        {
            AddAttribute addAttribute = new AddAttribute();

            this.Hide();
            addAttribute.Show();
        }
Exemplo n.º 3
0
        public ActionResult AddPost(AddViewModel model)
        {
            if (model.Files[0] == null || model.Files[1] == null || model.Files[2] == null)
            {
                ViewBag.Category = model.Category;
                ModelState.AddModelError("", "Must upload Files");

                return(View());
            }

            var    user     = db.Users.FirstOrDefault(x => x.Email == User.Identity.Name);
            string name     = Path.GetFileName(model.Files[0].FileName);
            string fileName = string.Concat(DateTime.Now.ToString("yyyyMMddHHmmssfff"), name);

            model.Files[0].SaveAs(Path.Combine(Server.MapPath("~/Data/User"), fileName));

            Ad ad = new Ad();

            ad.Condition   = model.Condition;
            ad.Title       = model.Title;
            ad.Description = model.Description;
            ad.Category    = model.Category;
            ad.City        = model.City;
            ad.State       = model.State;
            ad.Price       = model.Price;
            ad.UserId      = user.Id;
            ad.Image       = fileName;
            ad.Feature     = model.Feature;
            db.Ads.Add(ad);
            foreach (var image in model.Files)
            {
                string path     = string.Concat(DateTime.Now.ToString("yyyyMMddHHmmssfff"), Path.GetFileName(image.FileName));
                string Fullpath = Path.Combine(Server.MapPath("~/Data/User"), path);
                image.SaveAs(Fullpath);
                var img = new Image();
                img.AdId      = model.Id;
                img.ImagePath = path;



                db.Images.Add(img);
            }

            if (!(model.Attribute == null))
            {
                foreach (var item in model.Attribute)
                {
                    var attribute = new AddAttribute();
                    attribute.Attribute = item.key;
                    attribute.value     = item.value;
                    attribute.AdId      = model.Id;
                    db.AddAttributes.Add(attribute);
                }
            }
            db.SaveChanges();

            return(RedirectToAction("Category"));
        }
        public void TestUnconfirmedConfirmables()
        {
            var addAttribute = AddAttribute.From(_localNode, _set, _tracked);

            _consumables.Unconfirmed(addAttribute);

            Assert.NotEmpty(_consumables.AllTrackingIds);

            Assert.NotNull(_consumables.ConfirmableOf(addAttribute.TrackingId));
        }
 public static ReflectedPropertyTreeFactoryDefinition Create(AddAttribute attr, MethodBase ctor)
 {
     if (ctor.IsConstructor)
     {
         return(new ConstructorFactory(attr, ctor));
     }
     else
     {
         return(FromFactory(attr, (MethodInfo)ctor));
     }
 }
        public async Task AddAttribute(AddAttribute model)
        {
            var entity = new Data_Access_Layer.Attribute
            {
                Name = model.Name
            };

            await AttributeRepository.Add(entity);

            Save();
        }
        public async Task AddAttribute(AddAttribute model)
        {
            await RunTaskInTransaction(async() => {
                var attribute = new Data_Access_Layer.Attribute
                {
                    Name = model.Name
                };
                _sqliteConnection.Insert(attribute);

                return(string.Empty);
            });
        }
        protected ReflectedPropertyTreeFactoryDefinition(AddAttribute attr, MethodBase method, Type outputType)
        {
            this.info = new CommonReflectionInfo(this, attr ?? AddAttribute.Default, method);
            this.outputType = outputType;

            Type returnType;
            ConstructorInfo ctor = method as ConstructorInfo;
            if (ctor == null)
                returnType = ((MethodInfo) method).ReturnType;
            else
                returnType = ctor.DeclaringType;
        }
Exemplo n.º 9
0
        public void ApplyTransform_StringField_AmountAppendedToProperty()
        {
            var amount = 10;
            var record = new MockRecord()
            {
                StringField = "10"
            };
            var property     = typeof(MockRecord).GetProperty(nameof(MockRecord.StringField));
            var addAttribute = new AddAttribute(amount);

            addAttribute.ApplyTransform(property, record);

            Assert.AreEqual("1010", record.StringField);
        }
Exemplo n.º 10
0
        public void ApplyTransform_NullableDecimalField_AmountAddedToProperty()
        {
            var amount = 10;
            var record = new MockRecord()
            {
                NullableDecimalField = 10
            };
            var property     = typeof(MockRecord).GetProperty(nameof(MockRecord.NullableDecimalField));
            var addAttribute = new AddAttribute(amount);

            addAttribute.ApplyTransform(property, record);

            Assert.AreEqual(20, record.NullableDecimalField);
        }
Exemplo n.º 11
0
        public void ApplyTransform_NullValueWithNullableDoubleField_AmountAddedToProperty()
        {
            var amount = 10;
            var record = new MockRecord()
            {
                NullableDoubleField = null
            };
            var property     = typeof(MockRecord).GetProperty(nameof(MockRecord.NullableDoubleField));
            var addAttribute = new AddAttribute(amount);

            addAttribute.ApplyTransform(property, record);

            Assert.IsNull(record.NullableDoubleField);
        }
 public static ReflectedPropertyTreeFactoryDefinition FromFactory(AddAttribute attribute, MethodInfo method)
 {
     if (method.IsStatic)
     {
         return(new FactoryExtensionMethod(attribute, method));
     }
     if (typeof(IApplyProperties).IsAssignableFrom(method.DeclaringType))
     {
         return(new ApplyPropertiesMethod(attribute, method));
     }
     else
     {
         return(new FactoryMethod(attribute, method));
     }
 }
        public void TestIsRedistributableAsOf()
        {
            var addAttribute = AddAttribute.From(_localNode, _set, _tracked);

            _consumables.Unconfirmed(addAttribute);

            Assert.False(_consumables.ConfirmableOf(addAttribute.TrackingId).IsRedistributableAsOf());
            Assert.Empty(_consumables.AllRedistributable);

            while (_consumables.AllRedistributable.Count() != 1)
            {
                ;
            }
            Assert.Single(_consumables.AllRedistributable);
        }
        public void TestInboundStreamInterestAddAttribute()
        {
            var inboundStreamInterest =
                TestWorld.ActorFor <IInboundStreamInterest>(
                    () => new AttributesAgentActor(_localNode, Application, _outboundStream.Actor, Config, _interest));

            var message = AddAttribute.From(_localNode, _set, _tracked);

            inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, message));

            var channel1 = _channelProvider.ChannelFor(_localNodeId);

            Assert.Single(Mock(channel1).Writes);
            Assert.Equal(1, Application.InformAttributeAddedCheck.Get());
        }
        protected ReflectedPropertyTreeFactoryDefinition(AddAttribute attr, MethodBase method, Type outputType)
        {
            this.info       = new CommonReflectionInfo(this, attr ?? AddAttribute.Default, method);
            this.outputType = outputType;

            Type            returnType;
            ConstructorInfo ctor = method as ConstructorInfo;

            if (ctor == null)
            {
                returnType = ((MethodInfo)method).ReturnType;
            }
            else
            {
                returnType = ctor.DeclaringType;
            }
        }
 public static ReflectedPropertyTreeFactoryDefinition FromListAddMethod(MethodInfo method, bool naturalName = false)
 {
     if (naturalName)
     {
         if (string.IsNullOrEmpty(AddAttribute.GetNaturalName(method.DeclaringType)))
         {
             return(null);
         }
         else
         {
             return(new ListAddMethod(method, AddAttribute.Natural));
         }
     }
     else
     {
         return(new ListAddMethod(method, null));
     }
 }
        public void TestConfirmConfirmables()
        {
            var addAttribute = AddAttribute.From(_localNode, _set, _tracked);

            _consumables.Unconfirmed(addAttribute);

            Assert.Single(_consumables.AllTrackingIds);
            Assert.Equal(2, _consumables.ConfirmableOf(addAttribute.TrackingId).UnconfirmedNodes.Count());

            _consumables.Confirm(addAttribute.TrackingId, _remoteNode2);

            Assert.Single(_consumables.AllTrackingIds);
            Assert.Single(_consumables.ConfirmableOf(addAttribute.TrackingId).UnconfirmedNodes);

            _consumables.Confirm(addAttribute.TrackingId, _remoteNode3);

            Assert.Empty(_consumables.AllTrackingIds);
        }
Exemplo n.º 18
0
        public void TestInboundStreamInterestRemoveAttribute()
        {
            var inboundStreamInterest =
                TestWorld.ActorFor <IInboundStreamInterest>(
                    Definition.Has <AttributesAgentActor>(
                        Definition.Parameters(_localNode, Application, _outboundStream.Actor, Config, _interest)));

            var addMessage = AddAttribute.From(_localNode, _set, _tracked);

            inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, addMessage));
            var replaceMessage = RemoveAttribute.From(_localNode, _set, _tracked);

            inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, replaceMessage));

            var channel1 = _channelProvider.ChannelFor(_localNodeId);

            Assert.Equal(2, Mock(channel1).Writes.Count);
            Assert.Equal(1, Application.InformAttributeAddedCheck.Get());
            Assert.Equal(1, Application.InformAttributeRemovedCheck.Get());
        }
Exemplo n.º 19
0
 /// <summary>
 /// 設定主屬性額外加值屬性
 /// </summary>
 void SetModulateAttribute(string _str)
 {
     try
     {
         string[] strArray = _str.Split(':');
         ModulateAttribute = (MainAttribute)Enum.Parse(typeof(MainAttribute), strArray[0]);
         string[] addAttrStrs = strArray[1].Split(',');
         AddAttributes = new AddAttribute[addAttrStrs.Length];
         for (int i = 0; i < addAttrStrs.Length; i++)
         {
             string[]     values  = addAttrStrs[i].Split('+');
             AddAttribute addAttr = new AddAttribute((MinorAttribute)Enum.Parse(typeof(MinorAttribute), values[0]), int.Parse(values[1]));
             AddAttributes[i] = addAttr;
         }
     }
     catch (Exception ex)
     {
         Debug.LogWarning("Talent表設定ModulateAttribute時發生錯誤");
         Debug.LogException(ex);
     }
 }
Exemplo n.º 20
0
        internal void DistributeTo(
            AttributeSet set,
            TrackedAttribute tracked,
            ApplicationMessageType type,
            IEnumerable <Node> nodes)
        {
            switch (type)
            {
            case ApplicationMessageType.AddAttribute:
                var add            = AddAttribute.From(_node, set, tracked);
                var addConfirmable = _confirmables.UnconfirmedFor(add, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, add.ToPayload()), addConfirmable.UnconfirmedNodes);
                _application.InformAttributeAdded(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.RemoveAttribute:
                var remove            = RemoveAttribute.From(_node, set, tracked);
                var removeConfirmable = _confirmables.UnconfirmedFor(remove, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, remove.ToPayload()), removeConfirmable.UnconfirmedNodes);
                _application.InformAttributeRemoved(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.RemoveAttributeSet:
                var removeSet            = RemoveAttributeSet.From(_node, set);
                var removeSetConfirmable = _confirmables.UnconfirmedFor(removeSet, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, removeSet.ToPayload()), removeSetConfirmable.UnconfirmedNodes);
                _application.InformAttributeSetRemoved(set.Name);
                break;

            case ApplicationMessageType.ReplaceAttribute:
                var replace            = ReplaceAttribute.From(_node, set, tracked);
                var replaceConfirmable = _confirmables.UnconfirmedFor(replace, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, replace.ToPayload()), replaceConfirmable.UnconfirmedNodes);
                _application.InformAttributeReplaced(set.Name !, tracked.Attribute?.Name);
                break;

            default:
                throw new InvalidOperationException("Cannot distribute unknown ApplicationMessageType.");
            }
        }
Exemplo n.º 21
0
        public async Task <IActionResult> AddAttribute([FromBody] AddAttribute model)
        {
            await _unitOfWork.AddAttribute(model);

            return(Ok());
        }
 public FactoryMethod(AddAttribute attr, MethodBase method)
     : base(attr, method, GetReturnType(method))
 {
 }
 public ListAddMethod(MethodBase method, AddAttribute attr)
     : base(attr, method, method.GetParameters()[0].ParameterType)
 {
 }
 public static ReflectedPropertyTreeFactoryDefinition Create(AddAttribute attr, MethodBase ctor)
 {
     if (ctor.IsConstructor)
         return new ConstructorFactory(attr, ctor);
     else
         return FromFactory(attr, (MethodInfo) ctor);
 }
 public static ReflectedPropertyTreeFactoryDefinition FromFactory(AddAttribute attribute, MethodInfo method)
 {
     if (method.IsStatic)
         return new FactoryExtensionMethod(attribute, method);
     else
         return new FactoryMethod(attribute, method);
 }
 public ListAddMethod(MethodBase method, AddAttribute attr)
     : base(attr, method, method.GetParameters()[0].ParameterType)
 {
 }
Exemplo n.º 27
0
        public void GetNaturalName_should_consider_derived_argument_types(Type type, string expected)
        {
            string name = AddAttribute.GetNaturalName(type);

            Assert.Equal(expected, name);
        }
Exemplo n.º 28
0
        public void addon_method_implicit_builder_collection()
        {
            string name = AddAttribute.TrimImplicitAdd("AddNew", typeof(HelperBuilderCollection));

            Assert.Equal("helper", name);
        }
 public ApplyPropertiesMethod(AddAttribute attr, MethodBase method)
     : base(attr, method, method.GetParameters()[0].ParameterType)
 {
 }
 public ConstructorFactory(AddAttribute attr, MethodBase method) : base(attr, method, GetReturnType(method))
 {
 }
 public FactoryExtensionMethod(AddAttribute attr, MethodBase method)
     : base(attr, method, GetReturnType(method))
 {
 }
Exemplo n.º 32
0
 private void buttonAddAttr_Click(object sender, System.EventArgs e)
 {
     AddAttribute addAttr = new AddAttribute();
     addAttr.ShowDialog();
     listBoxFilterAttr.Items.Add(TagString(addAttr.AttributeGroup,addAttr.AttributeElement));
 }
Exemplo n.º 33
0
        public void addon_method_implicit_collection()
        {
            string name = AddAttribute.TrimImplicitAdd("AddNew", typeof(PropertyNodeCollection));

            Assert.Equal("propertyNode", name);
        }
Exemplo n.º 34
0
 /// <summary>
 /// 設定主屬性額外加值屬性
 /// </summary>
 void SetModulateAttribute(string _str)
 {
     try
     {
         string[] strArray = _str.Split(':');
         ModulateAttribute = (MainAttribute)Enum.Parse(typeof(MainAttribute), strArray[0]);
         string[] addAttrStrs = strArray[1].Split(',');
         AddAttributes = new AddAttribute[addAttrStrs.Length];
         for (int i = 0; i < addAttrStrs.Length; i++)
         {
             string[] values = addAttrStrs[i].Split('+');
             AddAttribute addAttr = new AddAttribute((MinorAttribute)Enum.Parse(typeof(MinorAttribute), values[0]), int.Parse(values[1]));
             AddAttributes[i] = addAttr;
         }
     }
     catch (Exception ex)
     {
         Debug.LogWarning("Talent表設定ModulateAttribute時發生錯誤");
         Debug.LogException(ex);
     }
 }
 public ConstructorFactory(AddAttribute attr, MethodBase method)
     : base(attr, method, GetReturnType(method))
 {
 }