示例#1
0
        //CRUD DELETE
        //POST a deletion/deactivation to the db
        //error checking
        //POST: /TSMaintenanceOrderGroup/DeleteMaintOrdGroup
        public string DeleteMaintOrdGroup(TSMaintenanceOrderGroupModel tsMaintenanceOrder)
        {
            try
            {
                //if the object has data, insert the data, else if there is no data just return a string

                //create a new MaintOrdGroup-type object called oMaintOrdGroup
                MaintOrdGroup oMaintOrdGroup = new MaintOrdGroup();

                //populate the DAL-object with the MVC object data
                oMaintOrdGroup.TA_Code       = tsMaintenanceOrder.TA_Code;
                oMaintOrdGroup.MaintOrdGroup = tsMaintenanceOrder.MaintOrdGrp;
                //set the object property to false. When you load the table in, with the
                //GetMaintOrdGroup() method called and filering in only active=true objects,
                //you'll only get the objects labelled as true (i.e. not "deleted")
                oMaintOrdGroup.Active = false;

                //connect via interface to DAL App, and delete the object. The DAL parses out just the equipment number, deleting the object with that number
                itsApp.DeleteMaintOrdGroup(oMaintOrdGroup);
                return("Deleted");
            }
            catch
            {
                return("Not Deleted");
            }
        }
示例#2
0
 //gets/reads Maintenance Orders by their id, used for tables
 //POST and GET: /TSMaintenanceOrderGroup/GetMaintOrdGroupByTA_Code
 public ActionResult GetMaintOrdGroupByTA_Code(TSMaintenanceOrderGroupModel tsMaintenanceOrder)
 {
     try
     {
         //gets entries as Dataview
         //stores the first table
         MaintOrdGroupByTA_Code = itsApp.GetMaintOrdGroupByTA_Code(tsMaintenanceOrder.TA_Code).Tables[0].DefaultView;
         //serializes/converts the DataView to JSON
         JavaScriptSerializer jsSerializer             = new JavaScriptSerializer();
         List <Dictionary <string, object> > parentRow = new List <Dictionary <string, object> >();
         Dictionary <string, object>         childRow;
         foreach (DataRow row in MaintOrdGroupByTA_Code.Table.Rows)
         {
             childRow = new Dictionary <string, object>();
             foreach (DataColumn col in MaintOrdGroupByTA_Code.Table.Columns)
             {
                 childRow.Add(col.ColumnName, row[col]);
             }
             parentRow.Add(childRow);
         }
         string JsSerializer = JsonConvert.SerializeObject(parentRow);
         return(Json(JsSerializer, JsonRequestBehavior.AllowGet));
     }
     //error handling, else it returns no value/null to the AngularJS method,
     catch
     {
         return(null);
     }
 }
示例#3
0
        //inserts/creates a Maintenance Order Group object in the DAL->db
        //POST: /TSMaintenanceOrderGroup/InsertMaintOrdGroup
        public string InsertMaintOrdGroup(TSMaintenanceOrderGroupModel tsMaintenanceOrder)
        {
            try {
                //create a new DAL-based TaskWO-type object called oTaskWO
                MaintOrdGroup oMaintOrdGroup = new MaintOrdGroup();

                //populate the DAL-object with the MVC object data
                oMaintOrdGroup.TA_Code       = tsMaintenanceOrder.TA_Code;
                oMaintOrdGroup.MaintOrdGroup = tsMaintenanceOrder.MaintOrdGrp;
                oMaintOrdGroup.Active        = tsMaintenanceOrder.Active;

                //connect via interface to DAL App, and insert the object
                itsApp.InsertMaintOrdGroup(oMaintOrdGroup);
                return("Added");
            }
            catch
            {
                return("Not Added");
            }
        }