Ejemplo n.º 1
0
        public IActionResult UrlDatasource([FromBody] DataManagerRequest dm)
        {
            IEnumerable    DataSource = OrdersDetails.GetAllRecords();
            List <string>  str        = new List <string>();
            DataOperations operation  = new DataOperations();

            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                DataSource = operation.PerformSorting(DataSource, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
            }
            int count = DataSource.Cast <OrdersDetails>().Count();

            if (dm.Skip != 0)
            {
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging
            }
            if (dm.Take != 0)
            {
                DataSource = operation.PerformTake(DataSource, dm.Take);
            }
            return(dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource));
        }
Ejemplo n.º 2
0
        public ActionResult Update([FromBody] ICRUDModel <OrdersDetails> value)
        {
            var           ord = value.value;
            OrdersDetails val = OrdersDetails.GetAllRecords().Where(or => or.OrderID == ord.OrderID).FirstOrDefault();

            val.OrderID    = ord.OrderID;
            val.EmployeeID = ord.EmployeeID;
            val.CustomerID = ord.CustomerID;
            val.Freight    = ord.Freight;
            val.OrderDate  = ord.OrderDate;
            val.ShipCity   = ord.ShipCity;

            return(Json(value.value));
        }
        public IActionResult UrlDatasource([FromBody] DataManagerRequest dm)
        {
            IEnumerable    DataSource = OrdersDetails.GetAllRecords();
            DataOperations operation  = new DataOperations();

            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
            {
                DataSource = operation.PerformSorting(DataSource, dm.Sorted);
            }
            List <string> str = new List <string>();

            if (dm.Aggregates != null)
            {
                for (var i = 0; i < dm.Aggregates.Count; i++)
                {
                    str.Add(dm.Aggregates[i].Field);
                }
            }
            IEnumerable aggregate = operation.PerformSelect(DataSource, str);

            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
            }
            int count = DataSource.Cast <OrdersDetails>().Count();

            if (dm.Skip != 0)
            {
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging
            }
            if (dm.Take != 0)
            {
                DataSource = operation.PerformTake(DataSource, dm.Take);
            }
            return(dm.RequiresCounts ? Json(new { result = DataSource, count = count, aggregate = aggregate }) : Json(DataSource));
        }
Ejemplo n.º 4
0
 //Delete the record
 public ActionResult Delete([FromBody] ICRUDModel <OrdersDetails> value)
 {
     OrdersDetails.GetAllRecords().Remove(OrdersDetails.GetAllRecords().Where(or => or.OrderID == int.Parse(value.key.ToString())).FirstOrDefault());
     return(Json(value));
 }
Ejemplo n.º 5
0
 //insert the record
 public ActionResult Insert([FromBody] ICRUDModel <OrdersDetails> value)
 {
     OrdersDetails.GetAllRecords().Insert(0, value.value);
     return(Json(value.value));
 }