public CompanyResponse CompanyIU(CompanyIURequest model) { var result = _AccountManagementService.CompanyIU(model); if (result.companyID == null) { result.companyID = "0"; } return(result); }
public CompanyResponse CompanyIU(CompanyIURequest model) { CompanyResponse resp = new CompanyResponse(); string _con = connection._DB_Master; DataTable dt = new DataTable(); SqlConnection oConn = new SqlConnection(_con); SqlTransaction oTrans; oConn.Open(); oTrans = oConn.BeginTransaction(); SqlCommand oCmd = new SqlCommand(); oCmd.Connection = oConn; oCmd.Transaction = oTrans; try { var folder = "code\\" + Crypto.url_decrypt(model.createdBy) + "\\5\\code"; var path = ""; if (model.companyID != "0") { if (model.img == "") { path = model.old_img; } else { path = folder + "\\" + model.img; } } else { if (model.img == "") { path = "Default\\Image\\default.png"; } else { path = folder + "\\" + model.img; } } oCmd.CommandText = "company_in_up"; oCmd.CommandType = CommandType.StoredProcedure; oCmd.Parameters.Clear(); oCmd.Parameters.AddWithValue("@company_id", model.companyID == "0" ? 0 : Crypto.url_decrypt(model.companyID)); oCmd.Parameters.AddWithValue("@company_code", model.companyCode); oCmd.Parameters.AddWithValue("@company_name", model.companyName); oCmd.Parameters.AddWithValue("@unit_floor", model.unit); oCmd.Parameters.AddWithValue("@building", model.building); oCmd.Parameters.AddWithValue("@street", model.street); oCmd.Parameters.AddWithValue("@barangay", model.barangay); oCmd.Parameters.AddWithValue("@municipality", model.municipality); oCmd.Parameters.AddWithValue("@city", model.SelectedCity); oCmd.Parameters.AddWithValue("@region", model.SelectedRegion); oCmd.Parameters.AddWithValue("@country", model.selectedCompanyCountry); oCmd.Parameters.AddWithValue("@zip_code", model.zipCode); oCmd.Parameters.AddWithValue("@company_logo", path); oCmd.Parameters.AddWithValue("@created_by", Crypto.url_decrypt(model.createdBy)); //oCmd.Parameters.AddWithValue("@active", model.active); SqlDataReader sdr = oCmd.ExecuteReader(); while (sdr.Read()) { resp.companyID = Crypto.url_encrypt(sdr["company_id"].ToString()); resp.createdBy = Crypto.url_encrypt(sdr["created_by"].ToString()); resp.companyCode = sdr["company_code"].ToString(); resp.company_series_code = (sdr["series_code"].ToString()); } sdr.Close(); oTrans.Commit(); oCmd.CommandText = "create_database"; oCmd.CommandType = CommandType.StoredProcedure; oCmd.Parameters.Clear(); oCmd.Parameters.AddWithValue("@series_code", resp.company_series_code); sdr = oCmd.ExecuteReader(); while (sdr.Read()) { resp.company_series_code = (sdr["series_code"].ToString()); } sdr.Close(); //oCmd.CommandText = "create_database_userdb"; //oCmd.CommandType = CommandType.StoredProcedure; //oCmd.Parameters.Clear(); //oCmd.Parameters.AddWithValue("@series_code", resp.company_series_code); //sdr = oCmd.ExecuteReader(); //while (sdr.Read()) //{ // resp.company_series_code = (sdr["series_code"].ToString()); //} //sdr.Close(); //oCmd.CommandText = "create_database_tenantsetupdb"; //oCmd.CommandType = CommandType.StoredProcedure; //oCmd.Parameters.Clear(); //oCmd.Parameters.AddWithValue("@series_code", resp.company_series_code); //sdr = oCmd.ExecuteReader(); //while (sdr.Read()) //{ // resp.company_series_code = (sdr["series_code"].ToString()); //} //sdr.Close(); //oCmd.CommandText = "create_database_branchdb"; //oCmd.CommandType = CommandType.StoredProcedure; //oCmd.Parameters.Clear(); //oCmd.Parameters.AddWithValue("@series_code", resp.company_series_code); //sdr = oCmd.ExecuteReader(); //while (sdr.Read()) //{ // resp.company_series_code = (sdr["series_code"].ToString()); //} //sdr.Close(); oCmd.CommandText = "create_table"; oCmd.CommandType = CommandType.StoredProcedure; oCmd.Parameters.Clear(); oCmd.Parameters.AddWithValue("@series_code", resp.company_series_code); sdr = oCmd.ExecuteReader(); while (sdr.Read()) { resp.company_series_code = (sdr["series_code"].ToString()); } sdr.Close(); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } finally { oConn.Close(); } return(resp); }