public ResponseModel CreateSLA([FromBody] SLAModel insertSLA) { int insertCount = 0; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newSLA = new SettingsCaller(); insertSLA.TenantID = authenticate.TenantId; insertSLA.CreatedBy = authenticate.UserMasterID; insertCount = newSLA.InsertSLA(new SLAServices(Cache, Db), insertSLA); statusCode = insertCount == 0 ? (int)EnumMaster.StatusCode.RecordAlreadyExists : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = insertCount; } catch (Exception) { throw; } return(objResponseModel); }
/// <summary> /// Create SLA /// <param name="SLAModel"></param> /// </summary> public int InsertSLA(SLAModel SLA) { List <int> ListSlaID = new List <int>(); int SLATargetInsertCount = 0; DataSet ds = new DataSet(); try { conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_InsertSLAMaster", conn); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@_tenantID", SLA.TenantID); cmd.Parameters.AddWithValue("@_createdBy", SLA.CreatedBy); cmd.Parameters.AddWithValue("@_issueType", SLA.IssueTypeID); cmd.Parameters.AddWithValue("@isSLAActive", Convert.ToInt16(SLA.isSLAActive)); cmd.Parameters.AddWithValue("@_SLAFor", SLA.SLAFor); MySqlDataAdapter da = new MySqlDataAdapter(); da.SelectCommand = cmd; da.Fill(ds); if (ds != null && ds.Tables.Count > 0) { if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int slaID = ds.Tables[0].Rows[i]["SLAIDS"] == System.DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["SLAIDS"]); if (slaID > 0) { ListSlaID.Add(slaID); } } } if (ListSlaID.Count > 0) { if (SLA.SLATarget.Count > 0) { for (int k = 0; k < ListSlaID.Count; k++) { for (int j = 0; j < SLA.SLATarget.Count; j++) { MySqlCommand Targetcmd = new MySqlCommand("SP_InsertSLATarget", conn); Targetcmd.Connection = conn; Targetcmd.Parameters.AddWithValue("@_slaID", ListSlaID[k]); Targetcmd.Parameters.AddWithValue("@_priorityID", SLA.SLATarget[j].PriorityID); Targetcmd.Parameters.AddWithValue("@_prioritySLABreach", SLA.SLATarget[j].SLABreachPercent); Targetcmd.Parameters.AddWithValue("@_priorityRespondValue", SLA.SLATarget[j].PriorityRespondValue); Targetcmd.Parameters.AddWithValue("@_priorityRespondDuraton", SLA.SLATarget[j].PriorityRespondDuration); Targetcmd.Parameters.AddWithValue("@_priorityResolutionValue", SLA.SLATarget[j].PriorityResolutionValue); Targetcmd.Parameters.AddWithValue("@_priorityResolutionDuraton", SLA.SLATarget[j].PriorityResolutionDuration); Targetcmd.Parameters.AddWithValue("@_createdBy", SLA.CreatedBy); Targetcmd.CommandType = CommandType.StoredProcedure; SLATargetInsertCount += Targetcmd.ExecuteNonQuery(); } } } } } } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } if (ds != null) { ds.Dispose(); } } return(SLATargetInsertCount); }
public int InsertSLA(ISLA SLA, SLAModel SLAm) { _SLA = SLA; return(_SLA.InsertSLA(SLAm)); }