コード例 #1
0
        public BaseEntity Post(string lang, BaseEntity entity, string parent = null)
        {
            var plugin = new Natec.Entities.CustomersPlugin();

            plugin.SetApiContext(apiContext);

            var requestData = new CustomersRequest()
            {
                IDType           = 0,
                ProfileType      = 1,
                Name             = entity.Name,
                ParentNode       = 1,
                StatusID         = 5,
                ParentID         = 1,
                isUpdateNodeTree = 1,
            };

            var results = new List <ValidationResult>();
            var isValid = Validator.TryValidateObject(requestData, new ValidationContext(requestData), results, true);

            if (!isValid)
            {
                throw new ArgumentException("request model is not valid");
            }

            BaseEntity rez;

            rez = plugin.Post("uk", requestData);

            return(rez);
        }
コード例 #2
0
        public void Delete(string Id)
        {
            if (!this.UserDeletingApproved)
            {
                return;
            }
            var plugin = new Natec.Entities.CustomersPlugin();

            plugin.SetApiContext(apiContext);
            plugin.Delete(Id);
        }
コード例 #3
0
        public BaseEntity Put(string id, string lang, BaseEntity entity)
        {
            var plugin = new Natec.Entities.CustomersPlugin();

            plugin.SetApiContext(apiContext);

            Natec.Widecoup.Customers_Response_GETBYID_OUTPUT pluginCustomerToEdit;

            pluginCustomerToEdit = (Customers_Response_GETBYID_OUTPUT)plugin.GetById(new Customers_Request_GETBYID
            {
                abn_ID = Int32.Parse(entity.Id),
                lang   = "uk"
            }, "uk").Item2;

            pluginCustomerToEdit.AbonentFullName = entity.Name;

            var requestData = new CustomersRequest()
            {
                IDType           = 0,
                ProfileType      = pluginCustomerToEdit.ProfileType,
                Name             = pluginCustomerToEdit.AbonentFullName,
                isUpdateNodeTree = 1,
                ID = pluginCustomerToEdit.abn_ExternalID
            };

            var validErr = new List <ValidationResult>();
            var isValid  = Validator.TryValidateObject(requestData, new ValidationContext(requestData), validErr, true);

            if (!isValid)
            {
                throw new ArgumentException("request model is not valid");
            }
            var rez = plugin.Put(pluginCustomerToEdit.abn_ID.ToString(), "uk", requestData);

            return(rez);
        }