// POST: api/ControlMaster /// <summary> /// Take the parameter of CONTROL_MASTER model type /// if CONTROL_MASTER.CM_ID = 0 or Null then it performs INSERT /// if CONTROL_MASTER.CM_ID > 0 and CONTROL_MASTER.DEL_FLG=N then it performs UPDATE /// if CONTROL_MASTER.DEL_FLG=Y then it performs DELETE /// </summary> /// <param name="cm"></param> public void Post([FromBody] CONTROL_MASTER cm) { if ((cm.CM_ID.HasValue ? cm.CM_ID.Value : 0) == 0) { _logicLayer.InsertControlMaster(cm); } else if (cm.CM_ID.Value > 0 && (string.IsNullOrWhiteSpace(cm.DEL_FLG) ? "N" : cm.DEL_FLG) == "N") { _logicLayer.UpdateControlMaster(cm); } else { _logicLayer.DeleteControlMaster(cm.CM_ID.Value); } }
internal void InsertControlMaster(CONTROL_MASTER cm) { using (var connection = MySqlDbConnection.NewConnection) { _statement = string.Format(MySQLquery.InsertControlMaster, string.Concat("'", cm.CONTROL_TYP, "'"), string.Concat("'", cm.NAME, "'"), string.Concat("'", cm.LABEL, "'"), string.Concat("'", cm.SAMPLE_PIC, "'"), string.Concat("'", string.IsNullOrWhiteSpace(cm.DEL_FLG) ? "N" : cm.DEL_FLG, "'"), string.Concat("'", string.IsNullOrWhiteSpace(cm.ORGL_USER) ? "ADMIN" : cm.ORGL_USER, "'"), "SYSDATE()" ); using (var command = MySqlDbConnection.Command(connection, _statement)) { command.ExecuteNonQuery(); } } }
internal void UpdateControlMaster(CONTROL_MASTER cm) { using (var connection = MySqlDbConnection.NewConnection) { _statement = string.Format(MySQLquery.UpdateControlMaster, string.IsNullOrWhiteSpace(cm.CONTROL_TYP) ? "CONTROL_TYP" : string.Concat("'", cm.CONTROL_TYP, "'"), string.IsNullOrWhiteSpace(cm.NAME) ? "NAME" : string.Concat("'", cm.NAME, "'"), string.IsNullOrWhiteSpace(cm.LABEL) ? "LABEL" : string.Concat("'", cm.LABEL, "'"), string.IsNullOrWhiteSpace(cm.SAMPLE_PIC) ? "SAMPLE_PIC" : string.Concat("'", cm.SAMPLE_PIC, "'"), string.IsNullOrWhiteSpace(cm.UPDT_USER) ? "UPDT_USER" : string.Concat("'", cm.UPDT_USER, "'"), "SYSDATE()", cm.CM_ID.Value ); using (var command = MySqlDbConnection.Command(connection, _statement)) { command.ExecuteNonQuery(); } } }
internal List <CONTROL_MASTER> GetAllControlMaster() { var ControlMaster = new List <CONTROL_MASTER>(); using (var connection = MySqlDbConnection.NewConnection) { _statement = string.Format(MySQLquery.GetControlMaster); using (var command = MySqlDbConnection.Command(connection, _statement)) { using (var reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { var controlMas = new CONTROL_MASTER(); controlMas.CM_ID = UtilityDL.CheckNull <int>(reader["CM_ID"]); controlMas.CONTROL_TYP = UtilityDL.CheckNull <string>(reader["CONTROL_TYP"]); controlMas.NAME = UtilityDL.CheckNull <string>(reader["NAME"]); controlMas.LABEL = UtilityDL.CheckNull <string>(reader["LABEL"]); controlMas.SAMPLE_PIC = UtilityDL.CheckNull <string>(reader["SAMPLE_PIC"]); controlMas.ORGL_STAMP = UtilityDL.CheckNull <DateTime>(reader["ORGL_STAMP"]); controlMas.ORGL_USER = UtilityDL.CheckNull <string>(reader["ORGL_USER"]); controlMas.UPDT_STAMP = UtilityDL.CheckNull <DateTime>(reader["UPDT_STAMP"]); controlMas.UPDT_USER = UtilityDL.CheckNull <string>(reader["UPDT_USER"]); controlMas.DEL_FLG = UtilityDL.CheckNull <string>(reader["DEL_FLG"]); ControlMaster.Add(controlMas); } } } } return(ControlMaster); } }
internal void UpdateControlMaster(CONTROL_MASTER cm) { _dac.UpdateControlMaster(cm); }
internal void InsertControlMaster(CONTROL_MASTER cm) { _dac.InsertControlMaster(cm); }
// PUT: api/Domain/5 public void Put([FromBody] CONTROL_MASTER cm) { _logicLayer.UpdateControlMaster(cm); }