コード例 #1
0
        public ActionResult Create()
        {
            var model = SqueezeJson();

            _productions.Insert(model);
            return(VidpubJSON(model));
        }
コード例 #2
0
        public OperationResult <Contact> AddContact(Contact contact)
        {
            var result = new OperationResult <Contact>();

            table.Insert(contact.ForInsert());
            return(result);
        }
コード例 #3
0
        public dynamic AddInvoice(dynamic invoice)
        {
            var invoices = new DynamicModel("invoicesDB", "invoice", "id");

            var addedInvoice = invoices.Insert(new {
                nroinvoice = invoice.nroinvoice,
                company    = invoice.company,
                customer   = invoice.customer
            });

            return(addedInvoice);
        }
コード例 #4
0
        public dynamic AddDetails(dynamic invoiceDetail)
        {
            var invoicesDetail = new DynamicModel("invoicesDB", "invoiceDetail", "id");
            var addedInvoice   = invoicesDetail.Insert(new
            {
                idInvoice   = invoiceDetail.idInvoice,
                productname = invoiceDetail.productname,
                quantity    = invoiceDetail.quantity,
                unitprice   = invoiceDetail.unitprice,
                subtotal    = invoiceDetail.subtotal
            });

            return(addedInvoice);
        }
コード例 #5
0
        public ActionResult Insert(dynamic viewModel, FormCollection formCollection)
        {
            var model = tbl.CreateFrom(formCollection);

            try
            {
                tbl.Insert(model);
            }
            catch (Exception x)
            {
                TempData["Error"] = "There was a problem adding this record";
            }

            return(null);
        }
コード例 #6
0
ファイル: DataManager.cs プロジェクト: Theoistic/Panda
        public static dynamic Process(DataProcessRequest request)
        {
            dynamic result = null;
            var     tbl    = new DynamicModel(ConnectionString, tableName: request.EntityType.Name, primaryKeyField: "Id");

            switch (request.Type)
            {
            case RequestType.GET:
                if (request.Object != null)
                {
                    throw new NotImplementedException();
                    //result = tbl.
                }
                else
                {
                    result = tbl.All();
                }
                break;

            case RequestType.POST:
                // Id is not allowed when doing an insert as this is the auto generated key as IDENTITY(1,1)
                IDictionary <string, object> map = ObjectExtensions.ToDictionary(request.Object);
                map.Remove("Id");
                result = tbl.Insert(map);
                break;

            case RequestType.UPDATE:
                result = tbl.Update(request.Object);
                break;

            case RequestType.PUT:
                throw new NotImplementedException();
                break;

            case RequestType.DELETE:
                throw new NotImplementedException();
                break;

            default:
                break;
            }
            return(result);
        }
コード例 #7
0
        /// <summary>
        /// Save record with information about entity change
        /// </summary>
        /// <param name="entityName">Entity name</param>
        /// <param name="entityKey">Entity key of changed record</param>
        /// <param name="changeType">Change type</param>
        /// <param name="description">Description for update change type</param>
        private void AddEntityChange(string entityName, string entityKey, EntityChangeType changeType, string description = null)
        {
            if (AdminInitialise.ChangeEntity == null)
            {
                return;
            }

            var table = new DynamicModel(AdminInitialise.ConnectionString, tableName: AdminInitialise.ChangeEntity.TableName, primaryKeyField: "EntityChangeId");

            dynamic changeRecord = new ExpandoObject();

            changeRecord.EntityName  = entityName;
            changeRecord.EntityKey   = entityKey;
            changeRecord.ChangeType  = changeType;
            changeRecord.Description = description;
            changeRecord.ChangedOn   = DateTime.UtcNow;
            changeRecord.ChangedBy   = HttpContext.Current.User.Identity.Name;

            table.Insert(changeRecord);
        }